Page 1 of 1

ECMAScript manual

Posted: Thu Jul 10, 2014 10:09 pm
by andrew
From a QCAD user:
Do you have a complete manual for ECMAScript that I can download to be sure I can do what I want?

Re: ECMAScript manual

Posted: Thu Jul 10, 2014 10:13 pm
by andrew
First, please note that 'ECMAScript' is the technically correct name for what is generally known as 'JavaScript'. Note that JavaScript is NOT Java and has nothing to do with Java at all, that's why I prefer the correct name 'ECMAScript'.

There are plenty of resources available on ECMAScript both online and as books. However, if you google for something related to ECMAScript, google the term 'JavaScript' instead to get more results.

You can find the QCAD API documentation at:
http://qcad.org/doc/qcad/latest/developer/

Since QCAD is based on the Qt framework, you can also access all Qt functionality from your scripts. The Qt API documentation:
http://qt-project.org/doc/qt-4.8/

Both that QCAD and the Qt APIs are pretty massive, so I recommend to mainly look at example code of tools similar to the one you need to get started. All tools offered by QCAD are to some degree implemented in ECMAScript, so you can find plenty of example code in the scripts directory of your QCAD installation or in our source code repository at:
https://github.com/qcad/qcad/tree/master/scripts

Re: ECMAScript manual

Posted: Sun Jul 13, 2014 10:21 am
by hungerburg
In addition to the API document, I have also found the built in debugger quite useful. Enable with a command line argument and trigger from your code with a statement. From a side panel I could drill through and see the available methods and fields in objects. Only useful, as long as the names speak for themselves, and mostly when one is exploring of course. Its a little like firebug in your favourite webbrowser though.