Custom Script Directory?

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
marcelrg
Registered Member
Posts: 1
Joined: Fri Nov 27, 2020 9:54 pm

Custom Script Directory?

Post by marcelrg » Fri Nov 27, 2020 10:02 pm

When I'm writing custom scripts is there a path that I can save them to other then

Code: Select all

C:\Program Files\QCAD\scripts\Misc\Examples
I would like to install my scripts in a directory off my homedir and have QCAD automatically add my scripts to the menu?

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

Re: Custom Script Directory?

Post by CVH » Sat Nov 28, 2020 6:00 am

Hi,
Assuming that you are a win user.
True, it can be annoying that windows interfere when it protects the OS portion.
I write, develop and debug my code with NPP in admin mode.
It works fine and on top NPP opens with everything the way I left it.

In a way we can:
- 'other than e.g. C:\Program Files\QCAD\scripts\Misc\Examples'
- 'install my scripts in a directory off my homedir'
- 'have QCAD automatically add my scripts to the menu'

But there are some basic concepts one has to obey.
First read:
https://www.ribbonsoft.com/en/tutorial- ... pt-actions
https://www.qcad.org/doc/qcad/3.0/devel ... rials.html

So, for a script to be added automatically to the menu:
- we need at least the folder structure under the script folder.
- with a minimal part of code explained in the tutorials.
- with an '.init' section to add them (automatically) to the menus.
To run custom code from outside the installation folder:
- 'include' the custom scripts in their folders or homedir at the top
- call the scripts, methods, functions.....

There is an example of one add on script I made on the fly:
https://qcad.org/rsforum/viewtopic.php?f=30&t=7497
One could migrate the core code itself to anywhere as long as we include a path to it.
There is much more on the Forum e.g.:
https://qcad.org/rsforum/viewtopic.php?f=32&t=6668


2 words of advice by Andrew:
- Start small and build up. :wink:
- The debugger mode is not intended for production use of QCAD :!:
(The last link explains my two shortcuts on the destop)

Hope this helps
Regards,
CVH

User avatar
andrew
Site Admin
Posts: 9052
Joined: Fri Mar 30, 2007 6:07 am

Re: Custom Script Directory?

Post by andrew » Mon Nov 30, 2020 9:53 am

You can add scripts to a "scripts" folder inside the folder returned by RSettings.getDataLocation().

Here that would be:
C:/Users/andrew/AppData/Local/QCAD/QCAD/scripts

Post Reply

Return to “QCAD 'How Do I' Questions”