Rhino3dmIO (File3dm.Objects.ToList() returns the right count but with all null values)

I am reading Rhino file using Rhino3dmIO module inside Revit. It reads the file but upon calling File3dm.Objects.ToList() returns all objects as nulls. I want to get InstanceReferenceGeometriy and InstanceDefinitionGeometry even after using filter it returns only nulls.

It seems there is a problem with my computer…same code worked on another computer :thinking:dont know what’s happening exactly.

find attached image.


Could it be a possible conflict between the 3dm reader that is shipped with Revit, and the one that is loaded with Rhino.Inside.Revit?

it seems that Rhino.RhinoDoc.ActiveDoc.Object.ToList() always returns null values but if you foreach or do something like Rhino.RhinoDoc.ActiveDoc.Object.Select(x=>x) it works fine.


1 Like

I am having the same problem but this is within a net6 solution with no Revit context. Was there a solution to this thread?

Hi @daniel4dev,

Are you using the C# version of Rhino3dm? As always, sample code that doesn’t work for you is helpful.


– Dale

Hi @dale,

Yes we are using the C# version of Rhino3dm, in all snippets I put below file is a File3dm type.

So at first we just tried to do var items = file.Objects.ToList() but got the error from above. Then I took the advice from above and tried var items = file.Objects.Select(x => x).ToList() but still got the error, but I think that’s because LINQ was simplifying expression so the select was essentially doing nothing. Then finally when I do var items = file.Objects.Where(x => true).ToList() I no longer get the error.

I think there might be something around the type of file.Objects inherits both from IList and IEnumerable and the IList implementation is failing so I need to force LINQ to query on the IEnumerable and casting file.Objects to IEnumerable doesn’t work either because LINQ is just too smart :laughing: