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?
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)