PolylineFromSelection and getAffectedObjects

This forum is for 'Work-in-Progress' QCAD user developed script Add Ons and Plug-ins.

Please use this forum to request/submit your script Add-Ons & Plug-in idea's.

Moderators: andrew, Husky, J-J

Post Reply
markb
Registered Member
Posts: 2
Joined: Fri May 08, 2020 2:50 pm

PolylineFromSelection and getAffectedObjects

Post by markb » Sat May 09, 2020 6:54 pm

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!

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

Re: PolylineFromSelection and getAffectedObjects

Post by CVH » Sun May 10, 2020 9:19 am

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

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

Re: PolylineFromSelection and getAffectedObjects

Post by andrew » Mon May 11, 2020 7:36 am

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.

markb
Registered Member
Posts: 2
Joined: Fri May 08, 2020 2:50 pm

Re: PolylineFromSelection and getAffectedObjects

Post by markb » Mon May 11, 2020 2:02 pm

excellent! Thank you!

Post Reply

Return to “QCAD 'Script Add-On & Plug-in challenge' - Work in Progress”