# Python - Set Family Parameter Values

**URL:** <https://forum.dynamobim.com/t/python-set-family-parameter-values/10608>\
**Category:** Developers\
**Tags:** python\
**Created:** [March 27, 2017, 5:13am UTC](https://forum.dynamobim.com/t/python-set-family-parameter-values/10608 "2017-03-27T05:13:57Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Matt\_Fleming](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/matt_fleming/32/8868_2.png) [@Matt\_Fleming](https://forum.dynamobim.com/u/Matt_Fleming)\
**Post date:** [March 27, 2017, 5:13am UTC](https://forum.dynamobim.com/t/python-set-family-parameter-values/10608/1 "2017-03-27T05:13:57Z")

</div>

Hi,

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:  
[python\_set\_param.py](https://forum.dynamobim.com/uploads/short-url/idhYH3MWXKMeRjUv677R9T7NeYi.py) (1.7 KB)

* * *

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

# Import RevitAPI

clr.AddReference(‘RevitAPI’)  
from Autodesk.Revit.DB import \*

# Import RevitAPIUI

clr.AddReference(‘RevitAPIUI’)

# Import DocumentManager and TransactionManager

clr.AddReference(‘RevitServices’)  
import RevitServices  
from RevitServices.Persistence import DocumentManager  
from RevitServices.Transactions import TransactionManager

# Import Dynamo Python References

clr.AddReference(‘ProtoGeometry’)  
from Autodesk.DesignScript.Geometry import \*

# Import RevitNodes

clr.AddReference(‘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  
#TransactionManager.Instance.EnsureInTransaction(doc)

# 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)  
outTC.append(typeMark.AsString())  
if param.IsShared and param.Definition.Name == param[1]:  
paramVal = i.get\_Parameter(param.GUID)  
outTC.append(paramVal.AsString())  
#Set BuiltInParameter Values  
#typeMark = c.Set(val)

#TransactionManager.Instance.TransactionTaskDone()  
OUT = outTC

---

<div class="post-metadata">

**Author:** ![T\_Pover](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/t_pover/32/19147_2.png) [@T\_Pover](https://forum.dynamobim.com/u/T_Pover)\
**Post date:** [March 27, 2017, 7:39am UTC](https://forum.dynamobim.com/t/python-set-family-parameter-values/10608/2 "2017-03-27T07:39:24Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Tomasz\_Puchala](https://avatars.discourse-cdn.com/v4/letter/t/5f9b8f/32.png) [@Tomasz\_Puchala](https://forum.dynamobim.com/u/Tomasz_Puchala)\
**Post date:** [March 27, 2017, 10:35am UTC](https://forum.dynamobim.com/t/python-set-family-parameter-values/10608/3 "2017-03-27T10:35:18Z")

</div>

Hi,  
try this  
[python\_set\_param\_changed.py](https://forum.dynamobim.com/uploads/short-url/3o0I1ybgV8jwcoMXxRj0LsiodVn.py) (1.8 KB)

---

<div class="post-metadata">

**Author:** ![Matt\_Fleming](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/matt_fleming/32/8868_2.png) [@Matt\_Fleming](https://forum.dynamobim.com/u/Matt_Fleming)\
**Post date:** [March 27, 2017, 3:12pm UTC](https://forum.dynamobim.com/t/python-set-family-parameter-values/10608/4 "2017-03-27T15:12:12Z")

</div>

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…?

[python\_set\_param\_rev1.py](https://forum.dynamobim.com/uploads/short-url/9rdycXyqEhK7hEsrncsueIjrMgM.py) (1.5 KB)

BuilderCoder uses a bip check in C# but I’m failing to translate to Python.  
[Built-In Param Checker](http://thebuildingcoder.typepad.com/blog/2011/09/unofficial-parameters-and-bipchecker.html)

---

<div class="post-metadata">

**Author:** ![Kulkul](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/kulkul/32/49801_2.png) [@Kulkul](https://forum.dynamobim.com/u/Kulkul)\
**Post date:** [March 27, 2017, 3:35pm UTC](https://forum.dynamobim.com/t/python-set-family-parameter-values/10608/5 "2017-03-27T15:35:55Z")

</div>

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

 ![](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/b/7/b7e8a35868a98e98b88fe00db07ad4f269fb1b37.jpg)

---

<div class="post-metadata">

**Author:** ![Matt\_Fleming](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/matt_fleming/32/8868_2.png) [@Matt\_Fleming](https://forum.dynamobim.com/u/Matt_Fleming)\
**Post date:** [March 27, 2017, 3:58pm UTC](https://forum.dynamobim.com/t/python-set-family-parameter-values/10608/6 "2017-03-27T15:58:57Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Einar\_Raknes](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/einar_raknes/32/8566_2.png) [@Einar\_Raknes](https://forum.dynamobim.com/u/Einar_Raknes)\
**Post date:** [March 27, 2017, 8:58pm UTC](https://forum.dynamobim.com/t/python-set-family-parameter-values/10608/7 "2017-03-27T20:58:02Z")

</div>

> [@Matt\_Fleming](#):
>
> Not sure where “CodeBlock” format went to?

See this:

> [@How to get help on the Dynamo forums](https://forum.dynamobim.com/t/how-to-get-help-on-the-dynamo-forums/4677/10):
>
> Whenever you need help with a python script, be sure to paste the code into your post, mark it and press the \</\> button: [image]
