Reverse item in a selectionset

Reverse item in a selectionset

BIM_VIET
Enthusiast Enthusiast
780 Views
2 Replies
Message 1 of 3

Reverse item in a selectionset

BIM_VIET
Enthusiast
Enthusiast
 

Hi all,

I have a list of object in "selectionset". Now i want create a new "selectionset" with object is reversed start from "11 to 0" as the picture below.

Please help me to find solution. I have tried to use Linq but can not convert Object to Selectionset, and can not file any parameter to sorted.

Thank you!

Selection set.jpg

0 Likes
Accepted solutions (1)
781 Views
2 Replies
Replies (2)
Message 2 of 3

_gile
Consultant
Consultant
Accepted solution

Hi,

 

I do not undesrtand what you're trying to achieve, but here's a way to create a new SelectionSet instance with the same objectIds in reveresd order. But you have to keep in mind the order of selected onjects in a selection set is not reliable.

 

var objectIds = selection.Value.GetObjectIds();
var reversedObjectIds = objectIds.Reverse().ToArray();
var reversedSelection = SelectionSet.FromObjectIds(reversedObjectIds);


Gilles Chanteau
Programmation AutoCAD LISP/.NET
GileCAD
GitHub

Message 3 of 3

BIM_VIET
Enthusiast
Enthusiast

it is wonderful working. How do you know it?

Please show me the way you can study it.

Thank you!

0 Likes