usingRhino.Commands;partialclassExamples{publicstaticRhino.Commands.ResultSelLayer(Rhino.RhinoDoc doc){// Prompt for a layer namestring layername = doc.Layers.CurrentLayer.Name;Result rc =Rhino.Input.RhinoGet.GetString("Name of layer to select objects",true,ref layername);if(rc !=Rhino.Commands.Result.Success)return rc;// Get all of the objects on the layer. If layername is bogus, you will// just get an empty list backRhino.DocObjects.RhinoObject[] rhobjs = doc.Objects.FindByLayer(layername);if(rhobjs ==null|| rhobjs.Length<1)returnRhino.Commands.Result.Cancel;for(int i =0; i < rhobjs.Length; i++)
rhobjs[i].Select(true);
doc.Views.Redraw();returnRhino.Commands.Result.Success;}}
importRhinoimport scriptcontext
importSystem.Guid,System.Drawing.ColordefSelLayer():# Prompt for a layer name
layername = scriptcontext.doc.Layers.CurrentLayer.Name
rc, layername =Rhino.Input.RhinoGet.GetString("Name of layer to select objects",True, layername)if rc!=Rhino.Commands.Result.Success:return rc
# Get all of the objects on the layer. If layername is bogus, you will# just get an empty list back
rhobjs = scriptcontext.doc.Objects.FindByLayer(layername)ifnot rhobjs:Rhino.Commands.Result.Cancelfor obj in rhobjs: obj.Select(True)
scriptcontext.doc.Views.Redraw()returnRhino.Commands.Result.Successif __name__=="__main__":SelLayer()
PartialClassExamplesPublicSharedFunctionSelLayer(ByVal doc AsRhino.RhinoDoc)AsRhino.Commands.ResultDim rc AsRhino.Commands.Result' Prompt for a layer nameDim layername AsString= doc.Layers.CurrentLayer.Name
rc =Rhino.Input.RhinoGet.GetString("Name of layer to select objects",True, layername)If rc <>Rhino.Commands.Result.SuccessThenReturn rc
' Get all of the objects on the layer. If layername is bogus, you will' just get an empty list backDim rhobjs AsRhino.DocObjects.RhinoObject()= doc.Objects.FindByLayer(layername)If rhobjs IsNothingOrElse rhobjs.Length<1ThenReturnRhino.Commands.Result.CancelEndIfFor i AsInteger=0To rhobjs.Length-1rhobjs(i).Select(True)Next
doc.Views.Redraw()ReturnRhino.Commands.Result.SuccessEndFunctionEndClass