第一次发表python代码,多多指教
功能:选中任何一个物件,与此物件相同图层的将被全部选中
[Python] 纯文本查看 复制代码 #coding=utf-8
import Rhino
import scriptcontext
import System.Guid
import rhinoscriptsyntax as rs
def DetermineObjectLayer():
rc, obref = Rhino.Input.RhinoGet.GetOneObject("请选择", True, Rhino.DocObjects.ObjectType.AnyObject)
if rc!=Rhino.Commands.Result.Success: return rc
rhobj = obref.Object()
if rhobj is None: return Rhino.Commands.Result.Failure
index = rhobj.Attributes.LayerIndex
name = scriptcontext.doc.Layers[index].Name
print "选中物件的图层名称是'", name, "'"
rs.Command ( "-_SelNone" )
rs.Command ( '-_SelLayer "' + name + '" _Enter' )
return Rhino.Commands.Result.Success
if __name__ == "__main__":
DetermineObjectLayer()
SelObjLayerAll.rar
(518 Bytes, 下载次数: 184)
调用脚本方法
|