Select object from code

Hi all!
I have next task.
Dialog

User will select object and its GUID adds to list.

But problem is in following. I would like to do highlighting objects in Rhino, when user select GUID in list.
“highlighting” means make object selected or smth like that.

Is it RhinoCommon or C++?
In C++ you can do this from the document object. Perhaps, take a look at it if it’s RhinoCommon

Unfortunately it’s RhinoCommon.
I found only SelectObject event in documentation nothing about methods. I feel that solution is somewhere nearby)

This is a tricky one.

You need to make a public variable inside your dialog. In your rhinocommand you can set that variable = doc. because if you use Dim doc as rhinodoc it does not know which document is doc.

After this you can

dosomething like this:

Dim l as new list(of guid)
For each a in listbox.selecteditems()
l.add(a)
Next

doc.objects.unselectall()
doc.objects.select(l)

Does that make sense? :stuck_out_tongue:

Sorry for the chaotic message.

1 Like

hah) I think it’s exactly what is need) :grinning:

good advice, thank you!

Maybe a doc.views.redraw() is needed also :wink: else it does not update your view…

1 Like

You helped me twice)

Hi, I had a similar question, is there a general way to select an object that you’ve just added to the document using the variable name of the object? (in rhinocommon)

or is the best solution to first add it to an array, and then select that array?

Hi. If you just added an object you can get the ID by

Dim myNewobject as guid = doc.objects.addbrep(myBrep)
doc.objects.unselectall()
doc.objects.select(myNewobject)

Something like this should work.

1 Like

awesome! this is exactly what I was looking for.