Copy Objects to Layer

落日映苍穹つ 2022-06-14 07:39 267阅读 0赞

这里写图片描述

  1. import rhinoscriptsyntax as rs
  2. def CopyObjectsToLayer():
  3. "Copy selected objects to a different layer"
  4. # Get the objects to copy
  5. objectIds = rs.GetObjects("Select objects")
  6. # Get all layer names
  7. layerNames = rs.LayerNames()
  8. if (objectIds==None or layerNames==None): return
  9. # Make sure select objects are unselected
  10. rs.UnselectObjects( objectIds )
  11. layerNames.sort()
  12. # Get the destination layer
  13. #ComboListBox:Displays a list of items in a combo-style list box dialog
  14. layer = rs.ComboListBox(layerNames, "Destination Layer <" + rs.CurrentLayer() + ">")
  15. if layer:
  16. # Add the new layer if necessary
  17. if( not rs.IsLayer(layer) ): rs.AddLayer(layer)
  18. # Copy the objects
  19. newObjectIds = rs.CopyObjects(objectIds)
  20. # Set the layer of the copied objects
  21. [rs.ObjectLayer(id, layer) for id in newObjectIds]
  22. # Select the newly copied objects
  23. rs.SelectObjects( newObjectIds )
  24. ##########################################################################
  25. # Check to see if this file is being executed as the "main" python
  26. # script instead of being used as a module by some other python script
  27. # This allows us to use the module which ever way we want.
  28. if( __name__ == "__main__" ):
  29. #call function defined above
  30. CopyObjectsToLayer()

发表评论

表情:
评论列表 (有 0 条评论,267人围观)

还没有评论,来说两句吧...

相关阅读