Create Layer isChildOf


#1

I’m trying this:

Dim Layer As New Rhino.DocObjects.Layer()
Layer.Name = "abc"
Layer.IsChildOf(MyLayer.LayerIndex)
Layer.CommitChanges()
Rhino.RhinoDoc.ActiveDoc.Layers.Add(Layer)

Have also tried to give the layer instead of LayerIndex.
Debugger gives an error that IsChildOf "object reference not set to an instance of an object"
Why?


(Dale Fugier) #2

To create a layer which is a child of another layer, you need to assign the “parent” layer’s id as the child layer’s parent id.

For example:

Dim parentLayer As New Rhino.DocObjects.Layer()
parentLayer.Name = "Parent"
Dim parentLayerIndex As Integer = doc.Layers.Add(parentLayer)

Dim childLayer As New Rhino.DocObjects.Layer()
childLayer.Name = "Child"
childLayer.ParentLayerId = doc.Layers(parentLayerIndex).Id
doc.Layers.Add(childLayer)

#3

Oke I was looking in the wrong directions Thanks Dale