Interactive Scripting [SOLVED]

Drop in here to discuss whatever you want.

Moderator: andrew

Forum rules

Always indicate your operating system and QCAD version.

Attach drawing files and screenshots.

Post one question per topic.

Post Reply
Joseph1916
Active Member
Posts: 36
Joined: Wed Jul 12, 2023 2:58 pm
Location: Florida

Interactive Scripting [SOLVED]

Post by Joseph1916 » Mon Jul 24, 2023 9:31 pm

https://qcad.org/en/tutorial-interactiv ... troduction

My Operating System - Ubuntu 22.04
QCAD 3.28.1

I did not expect success, but to get started, I attempted to build the code below using gcc compiler.

Error Messages:
gcc qcad-1.cpp
qcad-1.cpp:1:8: error: expected constructor, destructor, or type conversion before ‘(’ token
1 | include("scripts/EAction.js");
| ^
qcad-1.cpp:3:1: error: ‘function’ does not name a type; did you mean ‘union’?
3 | function ExMyMinimal(guiAction) {
| ^~~~~~~~
| union
qcad-1.cpp:7:1: error: ‘ExMyMinimal’ does not name a type
7 | ExMyMinimal.prototype = new EAction();
| ^~~~~~~~~~~
qcad-1.cpp:9:1: error: ‘ExMyMinimal’ does not name a type
9 | ExMyMinimal.init = function(basePath) {
| ^~~~~~~~~~~
End of error messages

Below is the subject CODE: (FROM Link at top of this message)
=========================================================================================
include("scripts/EAction.js");

function ExMyMinimal(guiAction) {
EAction.call(this, guiAction);
}

ExMyMinimal.prototype = new EAction();

ExMyMinimal.init = function(basePath) {
var action = new RGuiAction(qsTr("&Minimal Example"), RMainWindowQt.getMainWindow());
action.setRequiresDocument(true);
action.setScriptFile(basePath + "/ExMyMinimal.js");
action.setGroupSortOrder(100000);
action.setSortOrder(0);
action.setWidgetNames(["ExamplesMenu"]);
};
=========================================================================================

Any one willing to adventure into this SUBJECT !!
Obviously, not a good START !!

Joseph1916
Last edited by Joseph1916 on Sat Aug 05, 2023 10:34 pm, edited 1 time in total.

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

Re: Interactive Scripting

Post by CVH » Mon Jul 24, 2023 10:19 pm

Joseph1916,

Please post script related questions under 'QCAD Programming, Script Programming and Contributing'

What was wrong with your endeavor was that you included the line numbers.
ECMAScript has no line numbering.
True, GitHub will display line numbers and so do some textual tools like for example Notepad++ :wink:

Regards,
CVH

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

Re: Interactive Scripting

Post by andrew » Mon Jul 24, 2023 10:38 pm

Please note that this is code for a script (JavaScript), not C++ code. You do not need to compile the script. Simply put it in the scripts directory of your QCAD installation in a folder with the same name as the script.

From the tutorial you were following:

Note that in order for the script to be found, the file name needs to match the class name, i.e. "ExMyMinimal.js" in this case. It also needs to reside inside a directory with the same name "ExMyMinimal", so this script can for example be put into scripts/Misc/ExMyMinimal/ExMyMinimal.js.

Joseph1916
Active Member
Posts: 36
Joined: Wed Jul 12, 2023 2:58 pm
Location: Florida

Re: Interactive Scripting

Post by Joseph1916 » Mon Jul 24, 2023 10:42 pm

Will Do !!
Following along

Joseph1916
Last edited by Joseph1916 on Thu Aug 03, 2023 7:30 pm, edited 3 times in total.

Joseph1916
Active Member
Posts: 36
Joined: Wed Jul 12, 2023 2:58 pm
Location: Florida

Re: Interactive Scripting

Post by Joseph1916 » Thu Aug 03, 2023 2:57 pm

This Matter is solved. should be closed....

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

Re: Interactive Scripting

Post by CVH » Thu Aug 03, 2023 3:19 pm

Joseph1916 wrote:
Thu Aug 03, 2023 2:57 pm
This Matter is solved. should be closed....
Please edit your first post and add [SOLVED] to the title.

Regards,
CVH

Post Reply

Return to “Chat”