layer.FullPath returns differing results

When using layer.FullPath on the DocObject layer it is returning the layer.Name rather than the full path. However once the layer has been added to the document, doc.Layers[layerIndex].FullPath gets the correct value.

Is this how the layer.FullPath was intended to function? Below is some example code.

import Rhino
import scriptcontext

parent = Rhino.DocObjects.Layer.GetDefaultLayerProperties()
parent.Name = "Parent"
parentIndex = scriptcontext.doc.Layers.Add(parent)
parentId = scriptcontext.doc.Layers[parentIndex].Id

child = Rhino.DocObjects.Layer.GetDefaultLayerProperties()
child.Name = "Child"
child.ParentLayerId = parentId

childIndex = scriptcontext.doc.Layers.Add(child)
childLayer = scriptcontext.doc.Layers[childIndex]

print child.FullPath        ## prints Child ##

print childLayer.FullPath   ## prints Parent::Child ##


Hi Peter,

A couple of things going on here:

1.) doc.Layers.Add() makes a copy if the input Layer object. Thus, child and childLayer are not the same object.

2.) Layer.FullPath actually calls a function on the layer table. Thus, if the layer is not “in” the layer table, the function defaults to returning just it’s name.

Does this help?

– Dale