How do I run "Polyline From Selection"

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

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:

Regards
CVH

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.

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

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

di.selectAll();

This would be to use all entities.

Then, you can run:

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.

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

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

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.