I have written code to export geometries to 3dm.
If I try to open 3dm file created by this component in Rhino, it works fine. Every geometries are there as expected.
But if I try to import the file from GH using import 3dm component, it yields empty result as if nothing is there.
I have used Rhino.FileIO.File3dm.Read(path).Objects.Count property to get a better understanding of this problem and it returned correct number of objects count.
Am I doing something wrong here?
gh file I have attached have geometries internalized within the geometry container. try button and it will create a 3dm file. that particular file would not be recognized by import 3dm component but will open from rhino. I wll attach the 3dm file anyway.
I am suspecting the following lines :
Rhino.FileIO.File3dm file = new Rhino.FileIO.File3dm();
…
file.Write(path, 5); // I have tried 6, 0,1,2… all could not be read from GH import 3dm.
Doesn’t work here either. It could well be a bug in the IO import component.
Slightly too tipsy from dinner wine at the moment to investigate, but logged under RH-46981 for when I’m up and running again.
Took a while, but the layer index of your objects is all -1. The 3dm file contains a single layer, so I’d expect all the layer indices to be zero. At the moment my import code ignores all objects with an invalid layer index, since I cannot compare the layer name filter. I can change that so that it automatically accepts all unlayered objects, or at least displays a warning for unlayered objects, but I need to talk to the 3dm file format experts first to see how they feel about this.
The 3dm experts have told me that a layer index of -1 indicates the default layer in some cases, so technically the 3dm file you’re writing is not considered broken.
However you can assign layers to an object by giving it attributes that have the layer index set: 3dmWriteWithAttributes.gh (62.6 KB)