Python - Set Family Parameter Values



I’m trying to work on a Python Script that takes in a bunch of Family Types, Type Parameters and Values and set their values within the Project Environment.

I’m able to set System Family Parameters but I’m having troubles with loadable family types. To start off with, I’m unable to even get the Parameter values, as get_Parameter() is giving me errors. I should be able to cycle through the Parameters within the selected Family Type and get the values but I’m missing something. Then I should be able to use the element.Set(Value) I woud think?

current code below: (1.7 KB)

Or Below in odd Forum Format… Not sure where “CodeBlock” format went to?
import clr
import sys

Import RevitAPI

from Autodesk.Revit.DB import *

Import RevitAPIUI


Import DocumentManager and TransactionManager

import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager

Import Dynamo Python References

from Autodesk.DesignScript.Geometry import *

Import RevitNodes


Assign Labels to Revit Document and Application

doc = DocumentManager.Instance.CurrentDBDocument
app = DocumentManager.Instance.CurrentUIApplication.Application

doc = DocumentManager.Instance.CurrentDBDocument
uiapp = DocumentManager.Instance.CurrentUIApplication
app = uiapp.Application

famType = IN[0]
param = IN[1]
val = IN[2]
outTC =

builtInParmTM = BuiltInParameter.ALL_MODEL_TYPE_MARK
builtInParmComm = BuiltInParameter.ALL_MODEL_INSTANCE_COMMENTS

Cycle through all Family Element Types

for i in famType:
# Cycle through All Type Parameters from Family Type
for params in i.Parameters:
#Get BuiltInParameter Values
comments = i.get_Parameter(builtInParmComm)
typeMark = i.get_Parameter(builtInParmTM)
if param.IsShared and param.Definition.Name == param[1]:
paramVal = i.get_Parameter(param.GUID)
#Set BuiltInParameter Values
#typeMark = c.Set(val)

OUT = outTC



Hi Matt, to start off you should Unwrap the family types in your code like this:
famType = UnwrapElement(IN[0])

That should solve your first error, but there’s probably more to follow.



try this (1.8 KB)



I modified a little and got it working to get the Parameter Values.
Now I’m trying to remove

‘builtInParmTM = BuiltInParameter.ALL_MODEL_TYPE_MARK’

to avoid any issues when my input is a different BuiltInParameter, so I’m attempting to check if it’s a builtin and if so, get the param. But I can’t figure out how to get them correctly as p.GUID outputs error as it’s not a shared Param. I need to get the “ALL_MODEL_TYPE_MARK” or whatever the case is variable…? (1.5 KB)

BuilderCoder uses a bip check in C# but I’m failing to translate to Python.
Built-In Param Checker



@Matt_Fleming archi-lab package has nodes that can get you all the built in parameters of elements and also set them.



yea but I’m not looking for a node in this case, I’m just after Python.
I’m looking for what would be in “Get BuiltInParameter Name” node as an example.

I can get the BIP if I specifically declare it.

builtInParmTM = BuiltInParameter.ALL_MODEL_TYPE_MARK

But I’m not sure how to get the ‘.ALL_MODEL_TYPE_MARK’ for example from the parameter.



See this:

1 Like