Duplication of layout blocks

Please use this forum to post feedback and suggestions related to QCAD.

Moderator: andrew

Post Reply
ouilogique
Active Member
Posts: 39
Joined: Sun Feb 21, 2021 2:43 pm

Duplication of layout blocks

Post by ouilogique » Thu Aug 25, 2022 9:54 am

Would it be possible to give the possibility to duplicate layout blocks with the BY command? Currently, this command returns an error when applied to layout blocks. In French the error is “Impossible de copier le bloc d'espace modèle ou les blocs de mise en page.”

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

Re: Duplication of layout blocks

Post by CVH » Thu Aug 25, 2022 4:54 pm

Hi,
ouilogique wrote:
Thu Aug 25, 2022 9:54 am
Currently, this command returns an error when applied to layout blocks.
Indeed, Layouts are excluded for some reason ...

But there might be a workaround if it suits you, see:
https://qcad.org/rsforum/viewtopic.php?t=9031

I only can not say if it is fully developed.
It was not adopted by Andrew.

Regards,
CVH

ouilogique
Active Member
Posts: 39
Joined: Sun Feb 21, 2021 2:43 pm

Re: Duplication of layout blocks

Post by ouilogique » Sat Sep 03, 2022 10:55 am

Thank you for your answer CVH.

The script doesn't work for me. Here is what I tried.

I downloaded and unzipped the script

https://qcad.org/rsforum/download/file.php?id=11282

Then I added the path to the script directory in

Edit - Application Preferences - Widgets - Library Browser - Library Sources

I restarted QCAD, selected Layout1 and executed the BY command.

But the error persists.

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

Re: Duplication of layout blocks

Post by CVH » Sat Sep 03, 2022 11:27 am

ouilogique,

It is not a library item but an addon script.
There are some ways to implement it dependig your OS.

Or you can put a copy in its folder under your QCAD installation folder:
...QCAD\scripts\DuplicateLayoutBlock\ ... (4 files)
The complete path to the scriptfile should then read:
...QCAD\scripts\DuplicateLayoutBlock\DuplicateLayoutBlock.js
This folder structure is mandatory so that QCAD may locate your addon on startup.
However, on a Windows system this can be a protected area.

Or you can do the same but then in the local data location:
◦Windows: C:/Users/[Username]/AppData/Local/QCAD/QCAD ...
◦macOS: ~/Library/Application Support/QCAD/QCAD ...
◦Linux: ~/.local/share/QCAD/QCAD ...

In my case the full path then reads as:
C:\Users\[Username]\AppData\Local\QCAD\QCAD\scripts\DuplicateLayoutBlock\DuplicateLayoutBlock.js

All 4 files should be in the 'DuplicateLayoutBlock' folder.
Start or restart QCAD.

Regards,
CVH

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

Re: Duplication of layout blocks

Post by CVH » Sat Sep 03, 2022 11:37 am

ouilogique wrote:
Sat Sep 03, 2022 10:55 am
I restarted QCAD, selected Layout1 and executed the BY command.

But the error persists.
BTW, the shortcut of this tool is '22'.

Regards,
CVH

ouilogique
Active Member
Posts: 39
Joined: Sun Feb 21, 2021 2:43 pm

Re: Duplication of layout blocks

Post by ouilogique » Sat Sep 03, 2022 11:53 am

I am on macOS Monterey 12.5.1

I tried both solutions:

Copied the directory with 4 files to
~/Library/Application\ Support/QCAD/QCAD/DuplicateLayoutBlock

Copied the directory with 4 files to
/Applications/QCAD-Pro.app/Contents/Resources/scripts/DuplicateLayoutBlock

Restarted QCAD, but the result is still the same.

Regards,
ouilogique

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

Re: Duplication of layout blocks

Post by CVH » Sat Sep 03, 2022 12:16 pm

Not a mac guy, should that not be:
~/Library/Application Support/QCAD/QCAD/scripts/DuplicateLayoutBlock/... :wink:
('scripts' with a lower 's')

Don't forget to remove the misplaced items and folders and also remove it as a Library Sources.

Regards,
CVH

ouilogique
Active Member
Posts: 39
Joined: Sun Feb 21, 2021 2:43 pm

Re: Duplication of layout blocks

Post by ouilogique » Sat Sep 03, 2022 12:37 pm

Now it works and in fact the path in /Applications/QCAD-Pro.app that I mentioned previously was already working, but for this to work, you must not call the function with the BY command, but with the 22 command.
QCAD-duplicate-layout-command.jpg
QCAD-duplicate-layout-command.jpg (23.01 KiB) Viewed 12508 times

So both these folders work:

~/Library/Application\ Support/QCAD/QCAD/scripts/DuplicateLayoutBlock
/Applications/QCAD-Pro.app/Contents/Resources/scripts/DuplicateLayoutBlock

If you copy the script in both folders, the function appears twice.

But anyway, I don’t think it is wise to use the /Applications/QCAD-Pro.app folder as it will be overwritten each time the application is updated.

Thank you for your help.

Regards,
ouilogique

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

Re: Duplication of layout blocks

Post by CVH » Sun Sep 04, 2022 5:10 am

ouilogique wrote:
Sat Sep 03, 2022 12:37 pm
but for this to work, you must not call the function with the BY command, but with the 22 command.
Indeed, like mentioned above, if any then each tool needs a non conflicting shortcut.
I think that the two key stroke shortcut options starting with a 'B' are almost exhausted.

One can customize this in the App.Prefs. under General .. Tool Settings but it can not be 'BY'.
Or one could edit the DuplicateLayoutBlockInit.js file. Scripts are textual.
ouilogique wrote:
Sat Sep 03, 2022 12:37 pm
But anyway, I don’t think it is wise to use the /Applications/QCAD-Pro.app folder as it will be overwritten each time the application is updated.
That would be true when Andrew includes this tool in future releases.
However, there is the folder based system and I think he would implement it under the Block class:
https://github.com/qcad/qcad/tree/master/scripts/Block
If so, it would be another kind of collision.
But for some reason it is not adopted so far.

It also depends on how QCAD is installed. :wink:
I use a Win msi and my custom scripts under the App path remain untouched.
And I also use the local data location in some cases.

Regards,
CVH

Post Reply

Return to “QCAD Suggestions and Feedback”