How can I create polylines?

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
pietro_72_
Full Member
Posts: 81
Joined: Fri Apr 17, 2015 6:40 am
Location: http://creativitainformaticart.altervista.org

How can I create polylines?

Post by pietro_72_ » Mon Jun 12, 2017 11:27 am

Hello

How can I create polylines?
(I'm currently looking at scripts/Draw/Polyline/DrawPolyline/DrawPolyline.js)

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

Re: How can I create polylines?

Post by andrew » Mon Jun 12, 2017 12:00 pm

You might want to include "scripts/simple_create.js" and use the simplified API of QCAD:

For example:
addPolyline([ [ 100 , 0 ], [ 20 , -10 , 1 ], [ 0 , 40 , 0 , true ], [ -20 , -10 , 1 , true ] ]);

The full code (without using the simple API) would be:

Code: Select all

// doc is your RDocument
// di is your RDocumentInterface
var pl = new RPolylineEntity(doc, new RPolylineData());
pl.appendVertex(new RVector(x,y));
...
var op = new RAddObjectOperation(pl);
di.applyOperation(op);

pietro_72_
Full Member
Posts: 81
Joined: Fri Apr 17, 2015 6:40 am
Location: http://creativitainformaticart.altervista.org

Re: How can I create polylines?

Post by pietro_72_ » Thu Jun 15, 2017 8:06 am

I saw to close the polyline with "scripts / simple_create.js",
But to close the polyline with the full code?

Thank you

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

Re: How can I create polylines?

Post by andrew » Thu Jun 15, 2017 8:13 am

Please try to be more specific: what data or objects do you have and what do you want to achieve.

For example:
I have an RPolyline object representing a polyline that is open and wish to change it into a polyline that is closed.

Or:
I have a list of vectors and wish to create a closed polyline entity from them and add that to the drawing.

Or:
My drawing contains an open polyline entity which should be converted into a closed polyline entity. I know the ID of the polyline entity.

These are all quite different situations requiring different approaches.

pietro_72_
Full Member
Posts: 81
Joined: Fri Apr 17, 2015 6:40 am
Location: http://creativitainformaticart.altervista.org

Re: How can I create polylines?

Post by pietro_72_ » Thu Jun 15, 2017 1:50 pm

Well, maybe I do not need it, I've seen that fills can even be done without closing a polyline made of straight lines

Post Reply

Return to “QCAD Programming, Script Programming and Contributing”