[Rhino6] FileImportPlugIn.Load() no longer adds a "Default" layer in the document, warning "Turning on current layer"

We’re busy porting our plug-ins to Rhino 6 and I just noticed that when a file is loaded through a FileImportPlugIn (of which we have many), the “Default” layer is no longer present in the document. In Rhino5 this used to be the case. Fortunately, this can be solved by adding such a layer prior to importing any geometry. Is there a reason for this change?

One thing I noticed is that when no “Default” layer is present, that in at least one case I got a warning in Rhino after the file was loaded saying “Turning on current layer”. When a “Default” layer is added prior to loading, this warning does not appear. This warning is probably due to the fact that all the layers that are added during file import are by default turned off. The blocking warning is even shown when loading is performed in batch mode :sweat: :

image

Hi @menno,

Sorry I cannot answer your question. I’ll need to see some sample code that isn’t working, or that is working differently.

– Dale

Hi @dale

Just import whatever into a new layer and set the layer’s visibility to false on import. I just added the method below to a file import plug-in from the wizard. In Rhino 6 I get the aforementioned warning. In Rhino 5 I get a Default layer that is on, and a layer that is off with the point in it.

protected override bool ReadFile(string filename, int index, RhinoDoc doc, Rhino.FileIO.FileReadOptions options)
{
  int idx = doc.Layers.Add("My Dat Layer", System.Drawing.Color.DeepPink);
  if (idx < 0) return false;
      
  doc.Objects.AddPoint(new Point3d(0, 0, 0), new ObjectAttributes {LayerIndex = idx});

  var layer = doc.Layers[idx];
  layer.IsVisible = false;

  return true;
}

HI @menno,

Yes, I can confirm the behavior change between V5 and V6. Beyond this, is there anything else you need?

– Dale

Currently there is nothing, the other issue was also cleared up by John. I may encounter other things in the coming days/weeks, but so far everything is working.

I did encounter the new behaviour of the ControlPoint(x,y,z,w) constructor in v6 vs. v5. constructor, but this was well documented and has been resolved in our code base.