Room Geometry to DirectShape with materials

Room Geometry to DirectShape with materials

kevin_fielding
Advocate Advocate
387 Views
3 Replies
Message 1 of 4

Room Geometry to DirectShape with materials

kevin_fielding
Advocate
Advocate

Hi,

 

I'm try to create DirectShape representations of Room geometry inside revit, and need to apply materials to it. 

 

I can create a DirectShape directly from the Room.Geometry, however as you will be aware I cannot set the material of the geometry or its faces. I have had success converting the geometry using the TessellatedShapeBuilder which allows material assignment but produces triangulate geometry which is suboptimal for my application, especially in instances of curved walls and ceilings. 

https://github.com/jeremytammik/SpatialElementGeometryCalculator/blob/master/SpatialElementGeometryC... 

 

I presume the only other option would be to use the BRepBuilder to produce cleaner geometry. Does anyone know of any examples of this based on converting existing geometry and applying materials?

 

Thanks in advance. 

 

Kevin

0 Likes
Accepted solutions (1)
388 Views
3 Replies
Replies (3)
Message 2 of 4

ricaun
Advisor
Advisor
Accepted solution

This BRepBuilder looks complex and probably gonna be a nightmare to convert solid to that only to change the material.

 

I suppose Room geometry is always extrusion-based in the room outline, probably could be done with GeometryCreationUtilities.CreateExtrusionGeometry, but there is another way that gonna work in your case.

 

After you create your DirectShape and place it in the document you can Paint each face of the element using the Document.Paint, just get the geometry and paint each face. After you create the DirectShape you need to Regenerate the document before using the get_Geometry.

 

Room to Shape.gif

I used that same approach in the plugin ConduitMaterial to apply the material in the conduit and cable tray.

 

Works great.

 

Luiz Henrique Cassettari

ricaun.com - Revit API Developer

AppLoader EasyConduit WireInConduit ConduitMaterial CircuitName ElectricalUtils

0 Likes
Message 3 of 4

kevin_fielding
Advocate
Advocate

Thanks Luiz,

 

Extruding boundaries isn't preferable where Area and Volume calculations are used as it wouldn't represent the top face correctly.

 

That said, painting the DirectShape post-creation worked a treat, although this could allow users to remove the paint.

 

It's a shame you can't apply a material directly to the solid rather than iterating over the faces, having something similar to the applying materials to FreeFormElement in families, but inside a rvt project. It always seems a waste to lose cut representations of solid geometry. 

 

I know I could create a loadable family and load it in, but that's bloating the models unnecessarily in my opinion. 

 

Perhaps an idea for the Revit Ideas Station. 

 

Thanks for your assistance.

 

Kevin

 

 

 

0 Likes
Message 4 of 4

ricaun
Advisor
Advisor

Nobody gonna know that is painted, and the user still has the ability to repaint the face. I don't know what is the purpose of the Paint feature, but I'm glad that is exposed in Revit API and works great to fix the applied material in specific elements.

 

I was looking in the BRepBuilder and I was able to copy each face of a solid and create a new one with some specific material, but I don't know if works with any solid, some type of Faces is not allowed in the BRepBuilder.

 

Should be cool to have some methods in the SolidUtils to change the material of a solid or face.

 

Luiz Henrique Cassettari

ricaun.com - Revit API Developer

AppLoader EasyConduit WireInConduit ConduitMaterial CircuitName ElectricalUtils

0 Likes