How can I create polylines?

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

Moderator: andrew

Post Reply
pietro_72_
Active Member
Posts: 30
Joined: Fri Apr 17, 2015 6:40 am
Location: http://pietro72li.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: 5332
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_
Active Member
Posts: 30
Joined: Fri Apr 17, 2015 6:40 am
Location: http://pietro72li.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: 5332
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_
Active Member
Posts: 30
Joined: Fri Apr 17, 2015 6:40 am
Location: http://pietro72li.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 Developers and Contributors”