File3dmObjectTable Item missing

The following compiler error happens, when trying to use the Item property of File3dmObjectTable. In the documentation
Item property returns a array object, type File3dmObject. What am I missing?


using Rhino;
using Rhino.Geometry;
using Rhino.FileIO;
using Rhino.DocObjects;
using Rhino.DocObjects.Tables;

            path = String.Format("{0}BullFallsPlugin\\BullFallsProfiles\\Ring\\{1}3dm", BullFallsPlugIn.localRhinoDirectory, currentRingProfile);
            Rhino.FileIO.File3dm file3Dm = new Rhino.FileIO.File3dm();
            file3Dm = Rhino.FileIO.File3dm.Read( path );
            File3dmObjectTable table = file3Dm.Objects;
            var count = table.Count;
            var obj = table.Item[0];

Severity Code Description Project File Line Suppression State
Error CS1061 ‘File3dmObjectTable’ does not contain a definition for ‘Item’ and no extension method ‘Item’ accepting a first argument of type ‘File3dmObjectTable’ could be found (are you missing a using directive or an assembly reference?) BullFalls C:\Users\jim\Documents\RhinoPlugin\C#\BullFalls\BullFalls\Operations.cs 357 Active

This is an error* in the documentation, the following should work:

var count =table.Count;
var obj = table[0];

*maybe because documentation is auto-generated and the this[int index] array accessor is compiled to an Item under-the-hood.

Changed the code to your suggestion and now get the following error message.
|Error|CS0021|Cannot apply indexing with [] to an expression of type ‘File3dmObjectTable’|BullFalls|C:\Users\jim\Documents\RhinoPlugin\C#\BullFalls\BullFalls\Operations.cs|356|Active|

I have no idea, would need to look at code myself to verify.
I was just looking at this page for the indexing operator.

Here is the function that is called from a tabbed panel.
The expanded path, String.Format, is listed in the code. This is the file location on my machine.

        private void CfeateButton_click(object sender, EventArgs e)
            string path;
            Rhino.DocObjects.ObjRef A;
            Rhino.RhinoApp.RunScript("ShankArc", false);
            path = String.Format("{0}BullFallsPlugin\\BullFallsProfiles\\Ring\\{1}3dm", BullFallsPlugIn.localRhinoDirectory, currentRingProfile);
            // path = C: \Users\jim\AppData\Roaming\McNeel\Rhinoceros\6.0\BullFallsPlugin\BullFallsProfiles\Ring\Standard.3dm
            File3dm file3dm = new File3dm();
            file3dm = File3dm.Read( path );
            File3dmObjectTable table = file3dm.Objects;
            var count = table.Count;
            var obj = table[0];

Uploaded the file Standard.3dm.Standard.3dm (630.9 KB)

This line works in v5, but v6 doesn’t (layer names works, but sublayer name doesn’t)

File3dmObject[] objs = file3dm.Objects.FindByLayer(SUBLAYER_LAYERNAME);

What should be the correct form


Hi @rhino4u,

File3dmObjectTable.FindByLayer searches for objects by their layer name (only), not the full path name.

If you have a full path name, then you’ll need to recurse through the File3dmLayerTable until you find the required layer and pass that object to the File3dmObjectTable.FindByLayer override that take a Layer object.

– Dale

1 Like