If something is selected get name else do something


#1

Hi,

Let me explain my problem like this. I got a left and a right part. The object names are Left and Right.
I want to check if any of these are selected.

If left is selected do this
If right is selected do that
If nothing is selected ask which one should be selected (gonna do this with a dialog)

But the problem is if i use this:

Dim obref As Rhino.DocObjects.ObjRef = Nothing
Dim rc As Rhino.Commands.Result = Rhino.Input.RhinoGet.GetOneObject(“Select object”, True, Rhino.DocObjects.ObjectType.AnyObject, obref)
If rc <> Rhino.Commands.Result.Success Then
Return rc
End If

It will always ask if I want to select something and I want to work around that.
If nothing selected then ask which one too select else use the selected one.

Have tried to get an object name if something is selected with:

Dim myRhObj As Rhino.DocObjects.RhinoObject = doc.Objects.GetSelectedObjects(False, False)
Dim myObjName = myRhObj.Name
MsgBox(myObjName)

and then wanted to use this in an If statement but can’t even get this part working.
Can someone help me?

Jordy


(Dale Fugier) #2

Is this what you are looking for?

https://gist.github.com/dalefugier/6886610


#3

This is exactly what I’m looking for!
Thanks again :smile:
By setting go.EnablePostSelect(False) the user can’t select anything and only preselected objects will count right?


(Dale Fugier) #4

Correct.