Hello
How can I create polylines?
(I'm currently looking at scripts/Draw/Polyline/DrawPolyline/DrawPolyline.js)
How can I create polylines?
Moderator: andrew
Forum rules
Always indicate your operating system and QCAD version.
Attach drawing files, scripts and screenshots.
Post one question per topic.
Always indicate your operating system and QCAD version.
Attach drawing files, scripts and screenshots.
Post one question per topic.
-
- Full Member
- Posts: 83
- Joined: Fri Apr 17, 2015 6:40 am
- Location: http://creativitainformaticart.altervista.org
Re: How can I create polylines?
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:
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);
-
- Full Member
- Posts: 83
- Joined: Fri Apr 17, 2015 6:40 am
- Location: http://creativitainformaticart.altervista.org
Re: How can I create polylines?
I saw to close the polyline with "scripts / simple_create.js",
But to close the polyline with the full code?
Thank you
But to close the polyline with the full code?
Thank you
Re: How can I create polylines?
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.
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.
-
- Full Member
- Posts: 83
- Joined: Fri Apr 17, 2015 6:40 am
- Location: http://creativitainformaticart.altervista.org
Re: How can I create polylines?
Well, maybe I do not need it, I've seen that fills can even be done without closing a polyline made of straight lines