How to control material of geometry in new family?

I have an issue with my current workflow where whenever I update the geometry of a layer that is conveyed to a revit mass family, I lose the material that I select in Revit. This is important because I am using multiple materials to differentiate graphically between mass families and it gets reset to the default mass material. Is there a way to specify the material here?

Thanks!

You’ll want to use the family form component, it has a material input.

Here is what I am trying to avoid -

Let’s say I assign these mass forms a material (solid light blue)

As soon as i update the layer, it overwrites the family with the default material:

When I try to recreate this family using the Family Form, I can’t get it to write the new family:

I am able to pull the correct material in which is promising but I don’t know why the error is telling me “object reference not set to instance of an object”


?

@Japhy any more tips?

Does this help?


create-mass-family-with-material.gh (12.3 KB)

I was able to your script to work in a new Revit project. so something else was the issue on my end.