Imported CAD Data with LayerName
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I am importing solid geometry from dwg Imports and then using those points to generate topo’s. The simplified code that gets the points is below.
The project is experimental at the moment. The dwg’s include multiple objects other than just terrain so I need to be able to identify the “terrain” objects from the other objects. Clearly the layer name would be an ideal candidate for that. From this post I can see that a list of layers can be obtained from ImportInstance.Category.SubCategories but I’ve not managed to reconcile the items in that list with the individual geometry objects. This question was asked in 2014 and I’m wondering / hoping that its moved on and we can somehow filter the imported object by Layer?
ImportInstance dwg = MyImportInstance;
foreach (GeometryObject geometryObj in dwg.get_Geometry(opt))
{
if (geometryObj is GeometryInstance)
{
GeometryInstance dwgInstance = geometryObj as GeometryInstance;
GeometryElement instanceGeometryElement = dwgInstance.GetSymbolGeometry();
foreach (GeometryObject instObj in instanceGeometryElement)
{
// In this case i'm only interested in Solids.
// But object might be Mesh, PolyLine, Line, Arc, Etc.
if (instObj is Solid)
{
Solid solid = instObj as Solid;
if (null == solid || 0 == solid.Faces.Size || 0 == solid.Edges.Size)
continue;
// Get the faces and edges from solid
foreach (Face face in solid.Faces)
{
Mesh mesh = face.Triangulate();
// get points on the mesh and process as required, put into collections, etc.
}
}
}
}
}
Link copied