Dear Forum users,
I would like to get if the object tyoe in the File3dmObjectTable is Curve and add it into the type lists.
I have the below code as:
string str2 = "C:\\Users\\SAMSUNG\\Desktop\\C#-Rhino\\Case3yeni4.3dm";
File3dm file3dm = File3dm.Read(str2);
List<Curve> curves = new List<Curve>();
File3dmObjectTable ObjTab = file3dm.Objects;
for(int i=0;i<ObjTab.Count;i++)
{
if (ObjTab[i] ==Curve)
curves.Add(ObjTab[i]);
}
Here the main problem is can’t I use indexer [i] for File3dmObjectTable type ObjTab ? How could I get the ith item in the ObjTab list?
I appreciate for your help.
Best regards,
Ahmet
using Rhino.FileIO;
using Rhino.Geometry;
using System.Collections.Generic;
var path = @"C:\Users\SAMSUNG\Desktop\C#-Rhino\Case3yeni4.3dm";
var file3dm = File3dm.Read(path);
var crvs = new List<Curve>();
var objs = file3dm.Objects;
foreach(var item in objs)
{
if(item.Geometry is Curve crv)
crvs.Add(crv);
}
1 Like
Thank you for your help, @Mahdiyar .
@mahdiyar, I would like to ask what the type of “item” in your code is. You have declared it as “var” implicitly. However, I’m new and want to understand how the classes of Rhino works. Since you use “item.Geometry” expression, I wondered which class “item” belongs to.
I appreciate for your help.
Best Regards,
Ahmet
item
is of type File3dmObject. To determine the runtime type of any variable in C#, you can use the GetType() method.
1 Like
Thank you again, @Mahdiyar.