Unable to set Lineweight in 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
kellynews
Registered Member
Posts: 2
Joined: Mon May 16, 2022 2:34 pm

Unable to set Lineweight in script

Post by kellynews » Mon May 16, 2022 2:56 pm

Hello

I can create a dxf file with a script but when i try to specify a Lineweight the script fails at this line:
myLine.setLineweight(RLineweight::Weight100);

How should i adjust the line weight?

I am using qcad-3.27.5-pro-linux-x86_64.tar.gz on Ubuntu 20.04.3 LTS, command line.

Code: Select all

var spatialIndex = new RSpatialIndexSimple();
var document = new RDocument(storage, spatialIndex);
var di = new RDocumentInterface(document);

var operation = new RAddObjectsOperation();

var p1 = new RVector(7, 5);
var p2 = new RVector(10, 0);
var p3 = new RVector(5, Math.sin(RMath.deg2rad(60))*10);
 
var myLine = new RLineEntity(document, new RLineData(p1, p2));
myLine.setColor(new RColor("blue"));

myLine.setLineweight(RLineweight::Weight100)  // Fails at this line RScriptHandlerEcma::eval: script engine exception:  "SyntaxError: Parse error"

operation.addObject(myLine);
operation.addObject(new RLineEntity(document, new RLineData(p2, p3)));
operation.addObject(new RLineEntity(document, new RLineData(p3, p1)));

operation.apply(document);

di.exportFile("test-out-02.dxf", "DXF 2000");
Kind Regards

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

Re: Unable to set Lineweight in script

Post by andrew » Mon May 16, 2022 2:59 pm

"::" is the C++ notation. The JavaScript equivalent is:

myLine.setLineweight(RLineweight.Weight100)

kellynews
Registered Member
Posts: 2
Joined: Mon May 16, 2022 2:34 pm

Re: Unable to set Lineweight in script

Post by kellynews » Tue May 17, 2022 2:19 am

Awesome, thanks Andrew.
Its been a long long time since I last used c++, I will need to refresh it to the understand the qcad reference manual.

Post Reply

Return to “QCAD Programming, Script Programming and Contributing”