Getting the selected containers, in order

ruimac

Active member
I'm using the following code to get the selected containers:

Code:
    dim cnt_ids as Array[String]
    dim cmd,answer,sceneuuid as String
    sceneuuid = Scene.Uuid.FullString
    if sceneuuid = "<00000000-0000-0000-0000000000000000>" Then exit sub
    cmd = sceneuuid & "*EDITED_OBJECTS GET"
    answer = System.SendCommand(cmd)
    answer = answer.GetSubString(1,answer.Length-2)
    answer.Split(" ",cnt_ids)

In the cnt_ids array I get the ids of the selected containers. But I would like to make sure that the array is ordered, meaning that, if the whole hierarchy of the scene is opened, the first element of the array would correspond to the selected container this is the first selected from top to bottom... and so on, until the last element of the array corresponds to the selected container this is the lastselected from top to bottom.
Is there any way to assure that the array is sorted in that way. Or, at least, a way to get the selected container in the order they were selected.
 
Well, as a "solution" I coded a recursive code that goes through all the containers in the scene, from top to bottom. In each interaction, it checks if the current container id is in the array containing the ids of all selected containers. If it is, it stores that container in a new array.
So, I end up with an array that only contains selected containers, and they are ordered from top to bottom, according to the hierarchy.

Anyone knows a better "solution"?
 
not sure what are you trying to achieve but you can get the entire tree as json object, will that help?
in this script I save it to file but you can just put in a scene.map or something
 
Back
Top