usingSystem;partialclassExamples{publicstaticRhino.Commands.ResultFindObjectsByName(Rhino.RhinoDoc doc){conststring name ="abc";Rhino.DocObjects.ObjectEnumeratorSettings settings =newRhino.DocObjects.ObjectEnumeratorSettings();
settings.NameFilter= name;System.Collections.Generic.List<Guid> ids =newSystem.Collections.Generic.List<Guid>();foreach(Rhino.DocObjects.RhinoObject rhObj in doc.Objects.GetObjectList(settings))
ids.Add(rhObj.Id);if(ids.Count==0){Rhino.RhinoApp.WriteLine("No objects with the name "+ name);returnRhino.Commands.Result.Failure;}Rhino.RhinoApp.WriteLine("Found {0} objects", ids.Count);foreach(Guid id in ids)Rhino.RhinoApp.WriteLine(" {0}", id);returnRhino.Commands.Result.Success;}}
importRhinoimport scriptcontext
importSystem.GuiddefFindObjectsByName():
name ="abc"
settings =Rhino.DocObjects.ObjectEnumeratorSettings()
settings.NameFilter= name
ids =[rhobj.Idfor rhobj in scriptcontext.doc.Objects.GetObjectList(settings)]ifnot ids:
print "No objects with the name", name
returnRhino.Commands.Result.Failureelse:
print "Found",len(ids),"objects"for id in ids: print " ", id
returnRhino.Commands.Result.Successif __name__ =="__main__":FindObjectsByName()
PartialClassExamplesPublicSharedFunctionFindObjectsByName(ByVal doc AsRhino.RhinoDoc)AsRhino.Commands.ResultConst name AsString="abc"Dim settings AsNewRhino.DocObjects.ObjectEnumeratorSettings()
settings.NameFilter= name
Dim ids AsNewSystem.Collections.Generic.List(OfGuid)()ForEach rhObj AsRhino.DocObjects.RhinoObjectIn doc.Objects.GetObjectList(settings)
ids.Add(rhObj.Id)NextIf ids.Count=0ThenRhino.RhinoApp.WriteLine("No objects with the name "& name)ReturnRhino.Commands.Result.FailureElseRhino.RhinoApp.WriteLine("Found {0} objects", ids.Count)For i AsInteger=0To ids.Count-1Rhino.RhinoApp.WriteLine(" {0}",ids(i))NextEndIfReturnRhino.Commands.Result.SuccessEndFunctionEndClass