Rs.SelectedObjects() DOES NOT INCLUDE REF OBJS

rs.SelectedObjects() does not return selected objects if those objects are reference objects in a worksession file.

Is it possible to return selected / highlighted reference object GUID’s?

Perhaps something like the following might do for a workaround…

Edit: you wanted a list of object ID’s, corrected…

import Rhino
import scriptcontext as sc

def GetSelectedObjsIncRefObjs():
    oes = Rhino.DocObjects.ObjectEnumeratorSettings()
    oes.IncludeLights = False
    oes.IncludeGrips = False
    oes.NormalObjects = True
    oes.LockedObjects = False
    oes.HiddenObjects = False
    oes.ReferenceObjects = True
    oes.SelectedObjectsFilter = True
    objs=sc.doc.Objects.GetObjectList(oes)
    if objs:
        return [obj.Attributes.ObjectId for obj in objs]
    
def TestScript():
    objIds=GetSelectedObjsIncRefObjs()
    count="No"
    if objIds: count=len(objIds)
    print "{} objects selected".format(count)
TestScript()
1 Like

Added to wishlist/bugtracker:
http://mcneel.myjetbrains.com/youtrack/issue/RH-29727
–Mitch

1 Like