Quantcast
Channel: Scripting - McNeel Forum
Viewing all articles
Browse latest Browse all 5793

Layer name property empty, but object exists on layer

$
0
0

I’m trying to delete sublayers and move objects to their own parent layers, but even if object seems to be on renamed layer, properties shows empty on selected object layer name. How to solve this problem so that layer name appears also in properties?

Here’s my code:

import rhinoscriptsyntax as rs
import Rhino

def Layers2Top(layer):
    
    children = rs.LayerChildren(layer)
    if children:
        for child in children:
            objs=rs.ObjectsByLayer(child)
            if objs:
                newName = child.replace("::",":")
                print rs.AddLayer(newName)
                rs.ObjectLayer(objs,newName)
                rs.DeleteLayer(child)
                
if( __name__ == "__main__" ):
    layers = rs.LayerNames()
    if layers:
        for layer in layers:
            if rs.IsLayer(layer):
                #print layer
                Layers2Top(layer)

layers = rs.LayerNames()
for layer in layers:

    if layer in rs.LayerNames():
        if (layer):
            if rs.IsLayerEmpty(layer):
                rs.DeleteLayer(layer)

3 posts - 2 participants

Read full topic


Viewing all articles
Browse latest Browse all 5793

Trending Articles