Assign Layers in Rhino Based on Revit Material

Hi all - I’m trying to figure out a way to bring geometry from Revit into Rhino, after which the geometry is placed in a layer based on its material within Revit. My idea was to extract individual pieces of geometry by splitting the elements into parts, extracting the materials from the main element, making layers with the material names and assigning the correct layer attribute to each piece of geometry.

When I try complete the top part of the script using ‘Elements Parts Geometry’ more often than not, Revit crashes. I guess my question is - can this be done or should I find another way to filter the geometry into the correct layer?

See snippet of my script below. Thanks!

You’re on the right track. Cleaning your query to include only relevant elements is going to help stability.

Be aware that there might not be a direct correlation on the materials to Breps. Here there was one extra branch on the material side that would cause issues.

Thanks very much for your reply! Unfortunately whenever I run my adaptation of your script on a model that contains a very simple building, the number materials and the parts never seem to match up which results in a mismatch when assigning the attributes. Is there a way to ID a geometry part, find it in Revit and extract the material that way, or does the API only allow the extraction per element? Or is there another way to go about this?

We would need to look at an example does not work. but I expect there are some objects that is returning nulls in the lists and therefore not matching the lists correctly.