Hello,
This may be very basic. Please show me a link if it is already answered.
I have win 10 and QCAD ver 3.32.2, installed in late March.
Following the scripting tutorials, trying to add new menu/toolbar and new action, but when start QCAD, new menu / action don't show, and there is no error messages anywhere.
Here is the folder I made the file structure to follow the tutorial, also tried the installation scripts folder, same result.
C:\Users\**design\AppData\Roaming\QCAD\scripts
even added this to QCAD3.ini
[Scripts]
ScriptPath=C:/Users/**design/AppData/Roaming/QCAD/scripts, C:/Program Files/QCAD/scripts
EnableScripting=1
[Debug]
LogFile=C:/temp/qcad_debug.log
LogLevel=Debug
Anything missed in the QCAD installation?
can somebody help on this? thanks a lot.
Jeff
[SOLVED] QCAD to start with custom code
Moderator: andrew
Forum rules
Always indicate your operating system and QCAD version.
Attach drawing files and screenshots.
Post one question per topic.
Always indicate your operating system and QCAD version.
Attach drawing files and screenshots.
Post one question per topic.
-
- Newbie Member
- Posts: 3
- Joined: Wed May 14, 2025 4:18 pm
[SOLVED] QCAD to start with custom code
- Attachments
-
- DxfBlock.js
- (1 KiB) Downloaded 293 times
-
- Energy.js
- (711 Bytes) Downloaded 275 times
-
- folder-JS.jpg (10.49 KiB) Viewed 11942 times
Last edited by Jeffyu on Thu May 15, 2025 9:11 pm, edited 2 times in total.
-
- Premier Member
- Posts: 4879
- Joined: Wed Sep 27, 2017 4:17 pm
Re: QCAD to start with custom code
Hi, and welcome to the QCAD forum.
No, scripting under QCAD is not really considered as basic for many users.
But many things are standardized and logically ordered.
The folder structure under 'scripts' is like a mirror of the menus.
It can simply be uppercase 'ENERGY' and Camel-case 'Energy.js' for the script name.
Most QCAD tools are configured as Addons and then it is logical that setting these up uses a standardized method.
On startup QCAD scans all sub folders of the folder called 'scripts' for a JS file with the same name as the sub folder.
If found it tries to call the init() function to initialize the Addon.
Energy.init is never called because the script resides in the folder 'ENERGY'.
There are two ways to define the init() function:
- As a function included in the tool script itself (Called 'MyCustomScript' as example):
- Or included in a separate JS script called 'MyCustomScriptInit.js':
When the tool script has no init() function it textually adds 'Init' to the script base name and tries to locate that JS file.
If that exists in the same folder it calls the init() function there.
# You don't need to edit the QCAD3.ini at all.
Remove these unsupported and thus obsolete entries.
# After defining Energy.prototype it is common to set the base path:
# It may be required to handle a call like this.getTitle().
# In DxfBlock.js it is better to include Energy.js in direct relative to 'scripts' instead of as 1 level back:
# The beginEvent of DxfBlock.js calls Energy.prototype.beginEvent.call(this); and that is undefined and probably transferred to EAction.
Typically used to show the tools panel if any.
# Displaying a user message/info/warning can simply be handled by EAction:
# I would not rule out setting a default command.
# About sort orders ... In 2015 Andrew published a list and I think that this is still valid, see related topic.
I am about sure that your custom script is unrelated to the standard included 'Tutorials'.
Your custom menu should pop up far to the right when using a GroupSortOrder of 90000 for example.
The SortOrder is added to that, typically 100-200-300-... instead of 1-2-3-... within this menu.
That leaves room for later inserting a tool with order 150 for example.
Regards,
CVH
No, scripting under QCAD is not really considered as basic for many users.

But many things are standardized and logically ordered.
The folder structure under 'scripts' is like a mirror of the menus.
It can simply be uppercase 'ENERGY' and Camel-case 'Energy.js' for the script name.

Most QCAD tools are configured as Addons and then it is logical that setting these up uses a standardized method.
On startup QCAD scans all sub folders of the folder called 'scripts' for a JS file with the same name as the sub folder.
If found it tries to call the init() function to initialize the Addon.
Energy.init is never called because the script resides in the folder 'ENERGY'.
There are two ways to define the init() function:
- As a function included in the tool script itself (Called 'MyCustomScript' as example):
Code: Select all
MyCustomScript.init = function(basePath) { ... }
Code: Select all
function init(basePath) { ... }
If that exists in the same folder it calls the init() function there.
# You don't need to edit the QCAD3.ini at all.
Remove these unsupported and thus obsolete entries.
# After defining Energy.prototype it is common to set the base path:
Code: Select all
// Derive class Energy from class EAction:
Energy.prototype = new EAction();
Energy.includeBasePath = includeBasePath;
Code: Select all
Energy.prototype.getTitle = function() {
return Energy.getTitle();
};
Code: Select all
// include base class
include("scripts/Energy/Energy.js");
Typically used to show the tools panel if any.
# Displaying a user message/info/warning can simply be handled by EAction:
Code: Select all
DxfBlock.prototype.beginEvent = function() {
Energy.prototype.beginEvent.call(this);
EAction.handleUserMessage("DxfBlock is running.");
this.terminate();
};
# About sort orders ... In 2015 Andrew published a list and I think that this is still valid, see related topic.
I am about sure that your custom script is unrelated to the standard included 'Tutorials'.

Your custom menu should pop up far to the right when using a GroupSortOrder of 90000 for example.
The SortOrder is added to that, typically 100-200-300-... instead of 1-2-3-... within this menu.
That leaves room for later inserting a tool with order 150 for example.
Regards,
CVH
-
- Premier Member
- Posts: 4879
- Joined: Wed Sep 27, 2017 4:17 pm
Re: QCAD to start with custom code
Also ...
You can add custom scripts under the 'scripts' folder of your QCAD installation.
On Windows and installed with the msi installer that is under the 'Programs File' folder but guarded by the UAC.
Then you probably need Admin rights to change anything.
Another option is using the local data location, see QCAD Changelog and scroll down to 3.26.2 (2021/04/15)
There is mentioned: Windows: 'C:/Users/[Username]/AppData/Local/QCAD/QCAD'
The complete path to the 'scripts' folder there would be: 'C:/Users/[Username]/AppData/Local/QCAD/QCAD/scripts/...'
Remark that 'QCAD' occurs twice.
Recently Andrew advised to verify this, see related topic.
Start Misc .. Development .. Script Shell (GE) and execute: RSettings.getDataLocation()
In my case that is under 'AppData/Local' and not under 'AppData/Roaming'.
Also remark the difference in folder separator.
Mostly Windows can cope but in JS it must be a normal slash '/'.
Regards,
CVH
You can add custom scripts under the 'scripts' folder of your QCAD installation.
On Windows and installed with the msi installer that is under the 'Programs File' folder but guarded by the UAC.
Then you probably need Admin rights to change anything.
Another option is using the local data location, see QCAD Changelog and scroll down to 3.26.2 (2021/04/15)
There is mentioned: Windows: 'C:/Users/[Username]/AppData/Local/QCAD/QCAD'
The complete path to the 'scripts' folder there would be: 'C:/Users/[Username]/AppData/Local/QCAD/QCAD/scripts/...'
Remark that 'QCAD' occurs twice.

Recently Andrew advised to verify this, see related topic.
Start Misc .. Development .. Script Shell (GE) and execute: RSettings.getDataLocation()
In my case that is under 'AppData/Local' and not under 'AppData/Roaming'.
Also remark the difference in folder separator.
Mostly Windows can cope but in JS it must be a normal slash '/'.
Regards,
CVH
-
- Newbie Member
- Posts: 3
- Joined: Wed May 14, 2025 4:18 pm
Re: QCAD to start with custom code
Thank you very much for your time.
I am pretty new to this scripting part, will need to digest your information and post my progress later.
update:
so the most important first step is to put custom scripts in right location.
Another option is using the local data location, see QCAD Changelog and scroll down to 3.26.2 (2021/04/15)
There is mentioned: Windows: 'C:/Users/[Username]/AppData/Local/QCAD/QCAD'
my case is: 'C:/Users/[Username]/AppData/Local/QCAD/QCAD Professional', by running:
Start Misc .. Development .. Script Shell (GE) and execute: RSettings.getDataLocation()
then add scripts folder inside. Now I see my custom menu/action.
@CVH, I started from this tutorial: https://qcad.org/doc/qcad/3.0/developer/index.html, a bit confusion when installation scripts folder needs admin rights to add files.
Thanks again.
I am pretty new to this scripting part, will need to digest your information and post my progress later.
update:
so the most important first step is to put custom scripts in right location.
Another option is using the local data location, see QCAD Changelog and scroll down to 3.26.2 (2021/04/15)
There is mentioned: Windows: 'C:/Users/[Username]/AppData/Local/QCAD/QCAD'
my case is: 'C:/Users/[Username]/AppData/Local/QCAD/QCAD Professional', by running:
Start Misc .. Development .. Script Shell (GE) and execute: RSettings.getDataLocation()
then add scripts folder inside. Now I see my custom menu/action.
@CVH, I started from this tutorial: https://qcad.org/doc/qcad/3.0/developer/index.html, a bit confusion when installation scripts folder needs admin rights to add files.
Thanks again.
-
- Premier Member
- Posts: 4879
- Joined: Wed Sep 27, 2017 4:17 pm
Re: [SOLVED] QCAD to start with custom code
Hi,
Updating a comment/reply is not notified.
Stumbled on it while reviewing.
You can also install QCAD from a provided ZIP into any location.
Manually adding a desktop shortcut and file associations.
Tutorials, guidelines and many other things are usually 'as in general' and OS independent.
Regards,
CVH
Updating a comment/reply is not notified.
Stumbled on it while reviewing.
Yes, sub-folders of scripts and menus are like mirrors.
That is Windows related when QCAD was installed using the msi.
You can also install QCAD from a provided ZIP into any location.
Manually adding a desktop shortcut and file associations.
Tutorials, guidelines and many other things are usually 'as in general' and OS independent.
Regards,
CVH