Page 1 of 1

exec

Posted: Mon Dec 23, 2013 10:17 am
by sramp
Hi,
please , is there an example script to use with the -exec switch ?

I would like to trigger different QCad scripts from an another application and the -exec switch could be an easy way to do it.
I don't have a lot of experience with Javascript so I'm encountering some problems writing a script for the -exec argument.
I read in the forum that the script must have :
- filename equal the class name
- beginEvent function
In example it's not clear to me when and where the object should be created.

Code: Select all

function TestClass () {
    this.animal  = "cat";
    this.name = "toby";
}
 
TestClass.prototype.beginEvent = function() {
    qDebug("TestClass beginEvent");
    QMessageBox.information(null, "Animal", this.animal+" "+this.name);
}
Thanks in advance.
sramp

Re: exec

Posted: Tue Dec 24, 2013 5:58 pm
by andrew
sramp wrote:please , is there an example script to use with the -exec switch ?
You can launch any of the scripts (those which represent tools) provided with QCAD with the -exec switch.

For example to immediately start drawing lines:
./qcad -exec scripts/Draw/Line/Line2P/Line2P.js
Or to show the file open dialog:
./qcad -exec scripts/File/OpenFile/OpenFile.js
It might also be interesting to know that you can run the above examples if QCAD is already running. In that case, the running instance will trigger the given scripts. This provides a simple way to remote control QCAD.

Re: exec

Posted: Tue Dec 24, 2013 7:15 pm
by sramp
Hi Andrew,
thanks a lot for your reply. I've really appreciated.

Code: Select all

./qcad -exec scripts/File/OpenFile/OpenFile.js
OpenFile.js works as expected, I'll study the source code to discover where I'm wrong.

No luck for me instead for :

Code: Select all

./qcad -exec scripts/Draw/Line/Line2P/Line2P.js
In autostart.js (line 187)

Code: Select all

var action = RGuiAction.getByScriptFile(args[i]);
return null so nothing happens.
Also my examples scripts don't pass the RGuiAction.getByScriptFile.

I'm using QCAD-Pro 3.4.5 on a Mac OS X 10.7.5.

Thanks a lot again.
I wish you a nice holiday time!
Regards
Stefano

Re: exec

Posted: Tue Dec 31, 2013 7:34 pm
by sramp
Hi,
just an update before the end of the year :)
I have been able to create some scripts triggered by the -exec options.
It seems I set a wrong path during the init (setScriptFile).

Greetings
sramp