As of Dynamo version 1.3.3, there are no built-in nodes available to change the family type directly. To address this, a Python node was created specifically to change the family type of elements.
The approach is straightforward: it uses the Revit API’s Element.ChangeTypeId() method to update the element’s type. Additionally, a custom function was implemented to ensure that the output data structure matches the input structure, maintaining consistency.
Here is the core Python code:
object = UnwrapElement(IN[0])
type = UnwrapElement(IN[1])
def ChangeType(obj):
TransactionManager.Instance.EnsureInTransaction(doc)
if isinstance(obj, Element):
obj.ChangeTypeId(type.Id)
r = obj
else:
r = []
for e in obj:
if isinstance(e, Element):
e.ChangeTypeId(type.Id)
r.append(e)
else:
r.append(ChangeType(e))
TransactionManager.Instance.TransactionTaskDone()
return r
OUT = ChangeType(object)
xuebim
Follow the latest BIM developments in the architecture industry, explore innovative building technologies, and discover cutting-edge industry insights.
← Scan with WeChat















Must log in before commenting!
Sign Up