Announcements

Starting in December, we will archive content from the community that is 10 years and older. This FAQ provides more information.

Revit API Forum
Welcome to Autodesk’s Revit API Forums. Share your knowledge, ask questions, and explore popular Revit API topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Imported CAD Data with LayerName

1 REPLY 1
Reply
Message 1 of 2
grahamcook
440 Views, 1 Reply

Imported CAD Data with LayerName

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.
				}
			}
		}
	}
}

 

1 REPLY 1
Message 2 of 2
jeremy_tammik
in reply to: grahamcook

I am not an expert in the Revit UI. I would hope and expect there to be some kind of option in there to assign different graphics styles to the different imported CAD layers. Then, you might be able to pick up and differentiate those different styles in your code snippet by checking the GeometryObject GraphicsStyleId property:

  

https://www.revitapidocs.com/2022/4103f148-957e-3f44-9ccd-a5ed6702c689.htm

  

Jeremy Tammik Developer Advocacy and Support + The Building Coder + Autodesk Developer Network + ADN Open

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report