[Solved] Block: create library item location

Use this forum to ask questions about how to do things in QCAD.

Moderator: andrew

Forum rules

Always indicate your operating system and QCAD version.

Attach drawing files and screenshots.

Post one question per topic.

Post Reply
RobB
Full Member
Posts: 72
Joined: Sun May 26, 2019 4:02 pm
Location: Alpnach, Switzerland

[Solved] Block: create library item location

Post by RobB » Wed Aug 18, 2021 2:08 pm

Is there a place to set the preferred location for a new library block?
I have defined the top library location in the Library browser widget, but the command 'create library item' opens my home directory.

Thanks,
Robert
Last edited by RobB on Sun Oct 17, 2021 6:21 pm, edited 1 time in total.
Linux Mint 20 , qcadcam-3.24.3.10-pro-linux-x86_64

User avatar
J-J
Moderator
Posts: 502
Joined: Tue Mar 24, 2009 9:48 pm

Re: Block: create library item location

Post by J-J » Wed Aug 18, 2021 4:44 pm

Hi RobB,
the command 'create library item' opens my home directory
It is up to you where you wish to store your items. Create as many folders as you would when saving files. You may do that within the default library or create a personal one where you would normally save your files.
You may then declare the path within app pref in QCAD
JJ Win7 pro-64

RobB
Full Member
Posts: 72
Joined: Sun May 26, 2019 4:02 pm
Location: Alpnach, Switzerland

Re: Block: create library item location

Post by RobB » Wed Aug 18, 2021 5:01 pm

Hi J-J,
Yes, I have defined my library location tree in the app pref.
But that does not seem to influence which directory location opens, once I issue the command 'create library item' for a completed block.
It is always my home directory. Do I miss something?

Robert
Linux Mint 20 , qcadcam-3.24.3.10-pro-linux-x86_64

CVH
Premier Member
Posts: 3416
Joined: Wed Sep 27, 2017 4:17 pm

Re: Block: create library item location

Post by CVH » Wed Aug 18, 2021 7:22 pm

RobB wrote:
Wed Aug 18, 2021 5:01 pm
Yes, I have defined my library location tree in the app pref.
But that does not seem to influence which directory location opens, once I issue the command 'create library item' for a completed block.
It is always my home directory. Do I miss something?
That is by default ... hardcoded in CreateLibraryItem.js
See:
https://qcad.org/rsforum/viewtopic.php?t=7726
https://www.ribbonsoft.com/bugtracker/i ... sk_id=2128

Regards,
CVH

RobB
Full Member
Posts: 72
Joined: Sun May 26, 2019 4:02 pm
Location: Alpnach, Switzerland

Re: Block: create library item location

Post by RobB » Sat Sep 25, 2021 1:11 pm

The more I use it, that default is not great.
As many other users probably do, I keep all my data, drawings etc on a backend server.
Even a 'hardwired' link like 'home/qcadlib' could solve the problem.
Robert.
Linux Mint 20 , qcadcam-3.24.3.10-pro-linux-x86_64

User avatar
Husky
Moderator/Drawing Help/Testing
Posts: 4935
Joined: Wed May 11, 2011 9:25 am
Location: USA

Re: Block: create library item location

Post by Husky » Sat Sep 25, 2021 9:34 pm

Just my two cents ...
RobB wrote:
Sat Sep 25, 2021 1:11 pm
... that default is not great.
I agree!
RobB wrote:
Sat Sep 25, 2021 1:11 pm
As many other users probably do, I keep all my data, drawings etc on a backend server.
Second that too. Wherever you like to store your library items it should be outside the QCAD launch path / tree. Why?

1. This "Hardwired" path isn't working as coded. It should open the launch path + "/libraries" but it already fails to jump to that subdirectory "libraries". Ok, I've to admit that I'm not a coder ..... but it looks like that to me ...

2. (the much more important point!) Every QCAD update will ruin your library item organization.
Before a update QCAD tries to save the item below "C:\Program Files\qcad-3.25.0-pro-win64" and after a update the same task leads you to save to "C:\Program Files\qcad-3.26.0-pro-win64". Confusing for every user and it requires a manual step in with a file management tool to move the items to the new location.

In short: If I'm able to tell QCAD where to look for library items (Application Preferences/Widgets/Library Browser) then I should also be able to tell QCAD where to save a new created (BT) library item.
Work smart, not hard: QCad Pro
Win10/64, QcadPro, QcadCam version: Current.
If a thread is considered as "solved" please change the title of the first post to "[solved] Title..."

RobB
Full Member
Posts: 72
Joined: Sun May 26, 2019 4:02 pm
Location: Alpnach, Switzerland

Re: Block: create library item location

Post by RobB » Sun Sep 26, 2021 9:29 am

A fixed subdirectory in home could be a reasonable compromise.
I don't know how it is with Windows, but in Linux I would run a cron job to pickup what gets into home/qcadlib and send it to the backend.
And if I would stick to my own naming conventions, with a bit of python it might even end up in the right subdirectory...
However, running such a job directly in my home directory does not seem wise.
Robert
Linux Mint 20 , qcadcam-3.24.3.10-pro-linux-x86_64

CVH
Premier Member
Posts: 3416
Joined: Wed Sep 27, 2017 4:17 pm

Re: Block: create library item location

Post by CVH » Sun Sep 26, 2021 9:45 am

Confirmed:
It doesn't open the launch path + "/libraries" disregarding the fact that the folder exist or not.
Over here, Create Library Item (BT) initiates a file dialog with my desktop as destination folder.

Probably a bare path vs a QFileInfo clash, a file called "libraries" will not exist but it is functional as "/libraries/".

Also remark that all paths "C:\Program Files ..." may be guarded by the Windows system to write to.
In such case it doesn't serve anything to present the application path aka launch path.
All disregarding it is "C:\Program Files\qcad-3.25.0-pro-win64" or the general "C:\Program Files\QCAD" or "...QCADCAM" on Windows.
More appropriate would be the recently added User Documents Location, if that exists.

Storing the last used path similar to 'Save As' and many others is not a big deal. :P
It only requires a few lines of standard code and an entry in the QCAD.ini/conf file.

By preferences would work.
But I think that many would already be happy with the dialog opening the last used path. :wink:
Not that I use the library often, fixed that on the fly.

Regards,
CVH

CVH
Premier Member
Posts: 3416
Joined: Wed Sep 27, 2017 4:17 pm

Re: Block: create library item location

Post by CVH » Sun Sep 26, 2021 10:52 am

RobB wrote:
Sun Sep 26, 2021 9:29 am
A fixed subdirectory in home could be a reasonable compromise.
Nothing to it ... See the Private Message that I send you.

Regards,
CVH

RobB
Full Member
Posts: 72
Joined: Sun May 26, 2019 4:02 pm
Location: Alpnach, Switzerland

Re: Block: create library item location

Post by RobB » Sun Oct 03, 2021 2:04 pm

Thanks CVH,

The modified CreateLibraryItem.js that you gave me works very well.
The BT command now remembers the directory where I saved the selected block.

Regards, Robert
Linux Mint 20 , qcadcam-3.24.3.10-pro-linux-x86_64

CVH
Premier Member
Posts: 3416
Joined: Wed Sep 27, 2017 4:17 pm

Re: Block: create library item location

Post by CVH » Thu Oct 14, 2021 9:52 am

All,

The issue that Husky mentioned above was solved by forcing it to a path.
Appending "/libraries/" instead of "/libraries".

Otherwise, that can sometimes lead to the dialog suggesting the filename 'libraries.dxf'.
Usually when calling File.getSaveFileName() a complete filename is provided as suggestion.

The order of paths is now:
- A persistent saved path if that still exists
- The user document location + "/libraries/" if that exists
- The original launch path + "/libraries/"

Also added a test if the export was successful before updating the LibraryBrowser path and the persistent saved path.
I had to tweak including BlockDialog.js there dotdot isn't functional in a custom script over here.

To supersede the original CreateLibraryItem.js:
- Ensure that the next folder structure exist in your application path
"...\QCAD\scripts\Block\CreateLibraryItem\..."
(QCAD or QCADCAM or whatever folder that is used)
- With none, copy over all 5 files from GitHub: https://github.com/qcad/qcad/tree/maste ... ibraryItem
- Replace the script file CreateLibraryItem.js with the one below.
CreateLibraryItem.js
(4.38 KiB) Downloaded 359 times

This was the first revision.
- The launch path 'C:/Program Files/QCAD ...' may be guarded on a Windows system.
(Then RSettings.getDocumentsLocation() seems more appropriate)
- A pickpoint isn't required with a single Block Reference and we could suggest the block its name.
- Same goes when BT is used in block edit mode.
- BT can also be used while 'Edit Block In place' is active. (What I can/will not test given FS#2179)

I'll add the proposal(s) to https://www.ribbonsoft.com/bugtracker/i ... sk_id=2128

Regards,
CVH

CVH
Premier Member
Posts: 3416
Joined: Wed Sep 27, 2017 4:17 pm

Re: Block: create library item location

Post by CVH » Thu Oct 14, 2021 11:08 am

All,

Should be fixed in the next release (> 3.26.4.9).
The script on GitHub is already updated by Andrew, thanks.

One can delete any custom created folder and/or file before updating QCAD. :wink:

Regards,
CVH

Post Reply

Return to “QCAD 'How Do I' Questions”