Page 1 of 1
How can I create polylines?
Posted: Mon Jun 12, 2017 11:27 am
by pietro_72_
Hello
How can I create polylines?
(I'm currently looking at scripts/Draw/Polyline/DrawPolyline/DrawPolyline.js)
Re: How can I create polylines?
Posted: Mon Jun 12, 2017 12:00 pm
by andrew
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);
Re: How can I create polylines?
Posted: Thu Jun 15, 2017 8:06 am
by pietro_72_
I saw to close the polyline with "scripts / simple_create.js",
But to close the polyline with the full code?
Thank you
Re: How can I create polylines?
Posted: Thu Jun 15, 2017 8:13 am
by andrew
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.
Re: How can I create polylines?
Posted: Thu Jun 15, 2017 1:50 pm
by pietro_72_
Well, maybe I do not need it, I've seen that fills can even be done without closing a polyline made of straight lines