Page 1 of 1

How do I run "Polyline From Selection"

Posted: Thu Mar 12, 2020 5:15 pm
by daniel_frac
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

Re: How do I run "Polyline From Selection"

Posted: Thu Mar 12, 2020 5:35 pm
by CVH
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

Re: How do I run "Polyline From Selection"

Posted: Thu Mar 12, 2020 8:10 pm
by andrew
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.

Re: How do I run "Polyline From Selection"

Posted: Fri Mar 13, 2020 10:45 am
by daniel_frac
Sorry I forgot to mentioned I want to run this as a script no interactively

Re: How do I run "Polyline From Selection"

Posted: Fri Mar 13, 2020 12:24 pm
by andrew
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.

Re: How do I run "Polyline From Selection"

Posted: Fri Mar 13, 2020 12:55 pm
by daniel_frac
Is the tolerance a parameter a single floating nunber or a vector like new RVector(1.0e-3, 1.0e-3)

Re: How do I run "Polyline From Selection"

Posted: Fri Mar 13, 2020 1:03 pm
by daniel_frac
Also is there a way to do it rather than by selecting, but using a list of entities or id's?

Re: How do I run "Polyline From Selection"

Posted: Fri Mar 13, 2020 3:19 pm
by andrew
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.