How to get ObjectId in multiple Objects

I select multi object in group object. I want to show ObjectId of result but not. How can do that.

import Rhino
import rhinoscriptsyntax as rs
import scriptcontext as sc
crv=Rhino.Input.RhinoGet.GetMultipleObjects("Select objects", True,Rhino.DocObjects.ObjectType.AnyObject)
for cv in crv:
    cv=cv.Object()
    print cv.ObjectId()

import Rhino
import rhinoscriptsyntax as rs
import scriptcontext as sc

# GetMultipleObjects returns a tuple, since there is an 'out' parameter
# in the function call
result=Rhino.Input.RhinoGet.GetMultipleObjects("Select objects", True,Rhino.DocObjects.ObjectType.AnyObject)
# first item in tuple is the success 
success = result[0]==Rhino.Commands.Result.Success
# the second item is the list
crv = result[1]

# now you can loop over the crv list and access the items
for cv in crv:
    cv=cv.Object()
    print cv.ObjectId()

The .NET version of the command is https://developer.rhino3d.com/api/RhinoCommon/html/M_Rhino_Input_RhinoGet_GetMultipleObjects_1.htm .

The hard part is that this function has that out parameter. In Rhino IronPython that gets translated such that the actual result and the out parameter are put into a tuple, like I’ve shown in the improved sample.

This you can see also in the debug breakpoint you posted. In your code crv[0] holds the Rhino.Commands.Result value Success, crv[1] is the list Rhino.DocObjects.ObjRef[]. I renamed things a bit in my example to clarify.

/Nathan

1 Like

Thank you!