My First Script

Discussion forum for C++ and script developers who are using the QCAD development platform or who are looking to contribute to QCAD (translations, documentation, etc).

Moderator: andrew

Forum rules

Always indicate your operating system and QCAD version.

Attach drawing files, scripts and screenshots.

Post one question per topic.

Post Reply
bob
Newbie Member
Posts: 5
Joined: Tue Jun 14, 2022 5:14 pm

My First Script

Post by bob » Tue Jun 14, 2022 5:21 pm

Ubuntu 20.04 running qcad-3.27.6-trial-linux-x86_64

The javascript works if I run the script after starting qcad ("Misc/Development/Run Script"). I have some questions about this.

1. Where is the documentaion or declaration is for qWarning?
2. I've read that you should include simple.js. Is that no longer required?
3. Layer '0' still shows up. Can I rename '0' to 'main' or delete layer '0'?

Code: Select all

qWarning('hello');
var document = this.getDocument();
var di = this.getDocumentInterface();

addLayer('main');
addLayer('dimensions');
di.setCurrentLayer('main');
di.setCurrentColor(new RColor(255, 0, 0));

points = [
   [0, 0],
   [40, 0],
   [40, 40],
   [0, 40],
]

closed = true
relative = false
addPolyline(points, closed, relative)

autoZoom();
Thanks,
Bob

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

Re: My First Script

Post by andrew » Tue Jun 14, 2022 5:54 pm

bob wrote:
Tue Jun 14, 2022 5:21 pm
1. Where is the documentaion or declaration is for qWarning?
It's part of the Qt API. It prints to stderr.
bob wrote:
Tue Jun 14, 2022 5:21 pm
2. I've read that you should include simple.js. Is that no longer required?
When running a script through the GUI, chances are that "Simple.js" has already been included somewhere else. I'd still recommend to include it in your script to make sure it's included at least once.
bob wrote:
Tue Jun 14, 2022 5:21 pm
3. Layer '0' still shows up. Can I rename '0' to 'main' or delete layer '0'?
No. Layer '0' is part of the DXF/DWG standard and cannot be deleted or renamed.

bob
Newbie Member
Posts: 5
Joined: Tue Jun 14, 2022 5:14 pm

Re: My First Script

Post by bob » Tue Jun 14, 2022 6:12 pm

Thank you

Post Reply

Return to “QCAD Programming, Script Programming and Contributing”