How do I run "Polyline From Selection"

Use this forum to ask questions about how to do things in QCAD.

Moderator: andrew

Forum rules

Always indicate your operating system and QCAD version.

Attach drawing files and screenshots.

Post one question per topic.

Post Reply
daniel_frac
Junior Member
Posts: 10
Joined: Thu Nov 14, 2019 4:15 pm

How do I run "Polyline From Selection"

Post by daniel_frac » Thu Mar 12, 2020 5:15 pm

I'm a QCAD 3.23.0.0 (3.23.0) x86_64 Windows 10 Pro/user

I would like to create polylines from all the segments in my document.

Something along the lines of:

include("scripts/Pro/Draw/Polyline/PolylineFromSelection/PolylineFromSelection.js");

var ids = doc.queryAllEntities();
var op = new RMixedOperation();
PolylineFromSelection.createPolyline(op, ids, document, new RVector(1.0e-3, 1.0e-3));

Obviously this doesn't work as:
1) PolylineFromSelection there is no documentation for which method there are within the PolylineFromSelection object.
2) The arguments for such method and how to obtain the selection etc...

Could you please provide an example.

I couldn't find anything om the documentation or in the forum

I found examples for PolylineFromSegments (which expects a single entity) but not for PolylineFromSelection.

Best Regards
Daniel Hung

CVH
Premier Member
Posts: 3470
Joined: Wed Sep 27, 2017 4:17 pm

Re: How do I run "Polyline From Selection"

Post by CVH » Thu Mar 12, 2020 5:35 pm

There are methods described to launch a Qcad function from its scriptfile.
Including the things a user would set up when initiating the function.

But I have to look that one up too.
it won't be obvious ....
keywords; script, run, ...

Another example would be:
https://qcad.org/rsforum/viewtopic.php?f=32&t=6801

Regards
CVH

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

Re: How do I run "Polyline From Selection"

Post by andrew » Thu Mar 12, 2020 8:10 pm

daniel_frac wrote:
Thu Mar 12, 2020 5:15 pm
I would like to create polylines from all the segments in my document.
Do you just want to do this with a document or do you want to run it as part of a (more complex) script?

In the first case, simply select all segments and run Draw > Polyline > Polyline from Selection.

daniel_frac
Junior Member
Posts: 10
Joined: Thu Nov 14, 2019 4:15 pm

Re: How do I run "Polyline From Selection"

Post by daniel_frac » Fri Mar 13, 2020 10:45 am

Sorry I forgot to mentioned I want to run this as a script no interactively

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

Re: How do I run "Polyline From Selection"

Post by andrew » Fri Mar 13, 2020 12:24 pm

Assuming, di is your RDocumentInterface, first, you need to select all entities you want to use as segments for the new polylines. E.g.:

Code: Select all

di.selectAll();
This would be to use all entities.

Then, you can run:

Code: Select all

var counter = PolylineFromSelection.autoJoinSegments(di, tolerance);
Where tolerance is the maximum gap allowed between segments to still join them into a polyline. The return value is the number of polylines created.

Please keep in mind that PolylineFromSelection is not part of the public API but part of the proprietary API of QCAD Professional. Feel free to call this from your script, but keep in mind that this API might change in a future version.

daniel_frac
Junior Member
Posts: 10
Joined: Thu Nov 14, 2019 4:15 pm

Re: How do I run "Polyline From Selection"

Post by daniel_frac » Fri Mar 13, 2020 12:55 pm

Is the tolerance a parameter a single floating nunber or a vector like new RVector(1.0e-3, 1.0e-3)

daniel_frac
Junior Member
Posts: 10
Joined: Thu Nov 14, 2019 4:15 pm

Re: How do I run "Polyline From Selection"

Post by daniel_frac » Fri Mar 13, 2020 1:03 pm

Also is there a way to do it rather than by selecting, but using a list of entities or id's?

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

Re: How do I run "Polyline From Selection"

Post by andrew » Fri Mar 13, 2020 3:19 pm

Tolerance is a number.
Also is there a way to do it rather than by selecting, but using a list of entities or id's?
No.

Post Reply

Return to “QCAD 'How Do I' Questions”