Bug? C# Doc Layer Creation Rhino 8.6

Hello together

I’m a bit confused. I just updated my rhino from version 8.3.x to Rhino 8, 8.6.24101.05001.

Now I build a grasshopper plugin that automatically exports rhino dm files and puts a set of geometries in the appropriate layers. Now with the new update, it does not generate any layers any more and just puts them in the default layer. Was there any change to how I’m supposed to create and add layers to the rhino doc?

This is a snipped from this plugin

// Create headless doc
RhinoDoc doc = RhinoDoc.CreateHeadless(null);

// Iterate over geometries
for (int i = 0; i < geometryList.Count; i++)
    var geoGoo = geometryList[i];

    // Handle layer names
    string layerName = "Default";
    if (i < layerNamesList.Count && layerNamesList[i] != null)
        layerName = layerNamesList[i].Value;

    // Handle layer colors
    Color layerColor = Color.Black;
    if (i < layerColorsList.Count && layerColorsList[i] != null)
        layerColor = layerColorsList[i].Value;

    Layer layer = new Layer()
        Name = layerName,
        Color = layerColor

    int layerIndex = doc.Layers.Add(layer);

    GeometryBase geo = geoGoo.ScriptVariable() as GeometryBase;

    ObjectAttributes atb = new ObjectAttributes
        LayerIndex = layerIndex

    doc.Objects.Add(geo, atb);

So I found a solution to that in the end…

I saved the file as follows before:

doc.SaveAs(path); that worked in v8.3.x

Now in v8.6.x I had to change it to: doc.SaveAs(path,version,true,false,false,false); to get layers

Hope that it might help someone that stumbles over the same thing :slight_smile: