exec

Discussion forum for contributors and developers who are using the QCAD version 3 ECMAScript development platform or the C++ plugin interface or who are otherwise looking to contribute to QCAD (translations, documentation, etc).

Moderator: andrew

exec

Postby sramp » Mon Dec 23, 2013 10:17 am

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
sramp
Active Member
 
Posts: 26
Joined: Mon Dec 02, 2013 4:15 pm

Re: exec

Postby andrew » Tue Dec 24, 2013 5:58 pm

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.
User avatar
andrew
Site Admin
 
Posts: 2544
Joined: Fri Mar 30, 2007 6:07 am

Re: exec

Postby sramp » Tue Dec 24, 2013 7:15 pm

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
sramp
Active Member
 
Posts: 26
Joined: Mon Dec 02, 2013 4:15 pm

Re: exec

Postby sramp » Tue Dec 31, 2013 7:34 pm

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
sramp
Active Member
 
Posts: 26
Joined: Mon Dec 02, 2013 4:15 pm


Return to QCAD 3 Developers and Contributors

Who is online

Users browsing this forum: No registered users and 1 guest