I’m trying to put together a graph to set the function of layers in compound families (walls, roofs, floors, ceilings) and am stuck on the actual implementation of setting the function. I’ve shamelessly hacked up the FamilyType.SetCompoundLayerMaterial node from Clockwork and managed to restructure the node itself (woo!) and have managed to get the python to set the function IF I force it using MaterialFunctionAssignment.Substrate (or Finish1, Structure, etc.) However, that isn’t very useful long-term since the function might need to be something different depending on the family.
So - I’m obviously missing something in the Python code itself on how to allow the Layer Function to be an input and then executed based on the input but I’m stumped. Long term goal with this is to be able to filter everything by the material (i.e. 1/2" Metal Furring) and have all layers that have that material be set to a particular function (i.e. Substrate); however the application could easily go in a variety of other directions.
Stuff I’ve looked through that helped some:
The overall graph (currently only worrying about the function, the Substrate text in the code block doesn’t do anything at the moment.)
The hacked-up node:
The even more hacked up Python:
The code itself:
#from FamilyType.SetCompountLayerWidth #Clockwork Package import clr clr.AddReference('RevitAPI') from Autodesk.Revit.DB import * clr.AddReference("RevitServices") import RevitServices from RevitServices.Persistence import DocumentManager from RevitServices.Transactions import TransactionManager doc = DocumentManager.Instance.CurrentDBDocument famtypes = UnwrapElement(IN) indices = IN function = IN booleans = list() counter = 0 TransactionManager.Instance.EnsureInTransaction(doc) for ft in famtypes: try: cs = ft.GetCompoundStructure() cs.SetLayerFunction(indices[counter],MaterialFunctionAssignment.Substrate) ft.SetCompoundStructure(cs) booleans.append(True) except: booleans.append(False) counter += 1 TransactionManager.Instance.TransactionTaskDone() OUT = (famtypes,booleans)
TL;DR: How can I make the MaterialFunctionAssignment an input that will read a value (probably a string?), and pass it through the Python to modify the family?