How to randomize Adaptive Component family Material


I want to start by mentioning I am complete newbie to Dynamo and coding so I know the issue that I am running into is based on my limitations but I am hoping for some help while I learn.

What I am trying to figure out how to get an adaptive panel to randomize the material. I watched several video tutorials on how to get a elements and curtain wall panels to randomize the material and I was able to get that to work but when I try to apply a similar script to the adaptive component, I get a read only error that I can not get past. I did read that it was possible to write a python script to get past the read only message but I do not know python.
This is what I am hoping to create

The first pass that I tried was to modify the basic Revit adaptive checkboard family so it has the material set as an instance parameter but that doesn’t work. I then tried to change the material parameter to a type parameter thinking that I could randomize the adaptive panel types but also didn’t work.

Here are the three Revit 2022 files that I have setup. One has the curtain wall panel and the adaptive component material parameter set as an instance. The other has the material parameter as a type parameter so there are different types for each of the materials.

curtain wall test.rvt (1.8 MB)
divided surface.rvt (1.6 MB)
divided surface_instance parmater.rvt (1.6 MB)

Here is all the different scripts that I have tried but each one has a different issue. I just need one to work.

This is the curtain wall panel script that works with an instance material parameter. It works with the curtain wall test file.
1.0 Shuffle Curtain Panel Material_Manual.dyn (21.2 KB)

These two scripts are typing to change the material parameter which is an instance parameter
3.0 Randomize Divided Surface_Material_Manual.dyn (23.4 KB)
3.2 Randomize Divided Surface_Material_Manual.dyn (25.1 KB)

These two scripts are typing to change the panel type parameter
3.3 Randomize Divided Surface_Material_Manual.dyn (23.9 KB)
3.4 Randomize Divided Surface_Material_Manual.dyn (20.1 KB)

any help would be greatly appreciated.

Ken Marcus

Unfortunately there’s still no API for in-place elements, which would be required to modify the adaptive components inside the in-place host.

Hi Nick,

Thanks for getting back to me. Well that does seem like a limitation that they need to address given how hard Autodesk pushes using adaptive components. However, I do have a question for you. I noticed that if I edit the mass then select the divided surface, when I run the dynamo script that it will select the panels. When I run the 3.0 script that I included previously and this new script (3.21- see below), that process was required to select the panels and it does report that the panels are selected. I am totally fine with manually needing to select the panels, I just want to randomize the material. Isn’t there a way, once the panels are selected, to get the materials to change?

3.21 Randomize Divided Surface_Material_Manual.dyn (23.9 KB)
This was from what results from the 3.21 script

As you will see I get a read only error. This is where I thought, OK, if can’t get past the read only error maybe I change the material to a type parameter and then create multiple types with the different materials, can I change that the panel type instead. I tried that with my other scripts but those didn’t work.

It just seems that if I can select it and get the info on the panels, I should be able to change them.


Selecting the panels isn’t the issue. However, the panels themselves will be read-only outside of the in-place element. I wasn’t able to run Dynamo inside the in-place editing context, so I don’t think that’s an option.

Well that is a bummer. Thanks for looking and getting back to me. Much appreciated.

Nick, Is this at all a possible direction for a solution?

3.3 Randomize Divided Surface_Material_Manual.dyn (23.9 KB)

Again, unless you can figure out how to modify the elements inside the in-place edit context the method for changing the parameters doesn’t matter. A read-only parameter is read-only.

Got it, thanks