Page 1 of 1

PolylineFromSelection and getAffectedObjects

Posted: Sat May 09, 2020 6:54 pm
by markb
Hi there. I'm converting some user selections to Polyline with

Code: Select all

var di = getDocumentInterface();
PolylineFromSelection.autoJoinSegments(di, 0.001);
And I want to get the newly created polylines.
Normally I'd..

Code: Select all

var op = new RSomeOperation(...);
var transaction = operation.applyOperation(...)
var ids = transaction.getAffectedObjects();
But I don't know what type of op it is or how to access it's arguments (undocumented pro cmd as I understand it, though I'm running pro).
Everything I've tried so far has failed.
Can someone give me a quick example of how to get a handle to the results of this sort of command?
Thank you!

Re: PolylineFromSelection and getAffectedObjects

Posted: Sun May 10, 2020 9:19 am
by CVH
Similar Topic:
https://qcad.org/rsforum/viewtopic.php?t=7057

from what I understand that with a selection and a specified document interface:
var Counter = PolylineFromSelection.autoJoinSegments(di, 0.001);
simply would create the polys from the selection in the di and returns how much that are created.

So, probably the op is part of the method. :wink:

Andrew's note:
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.

Regards,
CVH

Re: PolylineFromSelection and getAffectedObjects

Posted: Mon May 11, 2020 7:36 am
by andrew
The function signature is:

Code: Select all

/**
 * Creates polyline(s) from selected entities in di using given tolerance.
 *
 * \param di RDocumentInterface
 * \param tolerance Tolerance
 * \param action RAction (usually caller or this)
 * \param useTransactionGroup True to add operations to current transaction group
 * \param selectResult Select resulting polylines
 *
 * \return Number of polylines created.
 */
PolylineFromSelection.autoJoinSegments = function(di, tolerance, action, useTransactionGroup, selectResult) { ... }
You can use:

Code: Select all

PolylineFromSelection.autoJoinSegments(di, tolerance, undefined, false, true);
This will select the new polylines after they are created, so you can query them as the current selection.

Re: PolylineFromSelection and getAffectedObjects

Posted: Mon May 11, 2020 2:02 pm
by markb
excellent! Thank you!