# Revit Family Parameters Value "Family Editor"

**URL:** <https://forum.dynamobim.com/t/revit-family-parameters-value-family-editor/8499>\
**Category:** Developers\
**Created:** [December 28, 2016, 3:35pm UTC](https://forum.dynamobim.com/t/revit-family-parameters-value-family-editor/8499 "2016-12-28T15:35:47Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Raul.Galdran](https://avatars.discourse-cdn.com/v4/letter/r/7feea3/32.png) [@Raul.Galdran](https://forum.dynamobim.com/u/Raul.Galdran)\
**Post date:** [December 28, 2016, 3:35pm UTC](https://forum.dynamobim.com/t/revit-family-parameters-value-family-editor/8499/1 "2016-12-28T15:35:47Z")

</div>

Someone @Kulkul@craig @Einar_Raknes could write the final code for reading the parameter value. Because i’m trying this and of course returns me the parameter name, not the value:

```
import clr

# Import RevitAPI
clr.AddReference("RevitAPI")
from Autodesk.Revit.DB import FamilyManager

# Import DocumentManager and TransactionManager
clr.AddReference("RevitServices")
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager

doc = DocumentManager.Instance.CurrentDBDocument

pl = doc.FamilyManager.Parameters

Name_Parameter = IN[0]
for p in pl:
	a = p.Definition.Name
	if a == Name_Parameter:
		OUT = p.Definition.Name
```

---

<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:** [December 28, 2016, 3:39pm UTC](https://forum.dynamobim.com/t/revit-family-parameters-value-family-editor/8499/2 "2016-12-28T15:39:32Z")

</div>

@Raul.Galdran

 ![](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/3/2/32be241acfdbb2a3270f0587759c671a88053df0.png)

---

<div class="post-metadata">

**Author:** ![Raul.Galdran](https://avatars.discourse-cdn.com/v4/letter/r/7feea3/32.png) [@Raul.Galdran](https://forum.dynamobim.com/u/Raul.Galdran)\
**Post date:** [December 28, 2016, 3:53pm UTC](https://forum.dynamobim.com/t/revit-family-parameters-value-family-editor/8499/3 "2016-12-28T15:53:09Z")

</div>

Thanks a lot Kulkul, the solution is working for number parameters!

---

<div class="post-metadata">

**Author:** ![Raul.Galdran](https://avatars.discourse-cdn.com/v4/letter/r/7feea3/32.png) [@Raul.Galdran](https://forum.dynamobim.com/u/Raul.Galdran)\
**Post date:** [December 28, 2016, 4:16pm UTC](https://forum.dynamobim.com/t/revit-family-parameters-value-family-editor/8499/4 "2016-12-28T16:16:28Z")

</div>

@Kulkul the solutions is not working for text parameter. You know why this could happen?

---

<div class="post-metadata">

**Author:** ![Mostafa\_El\_Ayoubi](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/mostafa_el_ayoubi/32/7815_2.png) [@Mostafa\_El\_Ayoubi](https://forum.dynamobim.com/u/Mostafa_El_Ayoubi)\
**Post date:** [December 28, 2016, 6:44pm UTC](https://forum.dynamobim.com/t/revit-family-parameters-value-family-editor/8499/5 "2016-12-28T18:44:34Z")

</div>

Hi @Raul.Galdran ,

this should handle all parameter types :

```
import clr

# Import RevitAPI
clr.AddReference('RevitAPI')
from Autodesk.Revit.DB import FamilyManager

# Import DocumentManager and TransactionManager
clr.AddReference('RevitServices')
import RevitServices
from RevitServices.Persistence import DocumentManager

doc = DocumentManager.Instance.CurrentDBDocument
s = doc.FamilyManager.CurrentType

pl = doc.FamilyManager.Parameters

Name_Parameter = IN[0]

p = [i for i in pl if i.Definition.Name == Name_Parameter][0]

try:
	v = s.AsString(p)
except:
	try :
		v = s.AsValueString(p)
	except :
		try:
			v = s.AsDouble(p)
		except:
			v = s.AsInteger(p)

OUT = v
```

---

<div class="post-metadata">

**Author:** ![Raul.Galdran](https://avatars.discourse-cdn.com/v4/letter/r/7feea3/32.png) [@Raul.Galdran](https://forum.dynamobim.com/u/Raul.Galdran)\
**Post date:** [December 29, 2016, 9:12am UTC](https://forum.dynamobim.com/t/revit-family-parameters-value-family-editor/8499/6 "2016-12-29T09:12:56Z")

</div>

I tried your code and at least for me doesn’t work with Length Parameters:

 ![](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/1/7/1754e33dd1d7bb5d931c8f0a6471d3bf38a6309c.PNG)

The one up is yours. And the one down is mine, yesterday i managed to find a way. Still needs a little bit of work so it can read all type of parameter but at least can read text and length parameters. I’ll like also integer and number but i think is just adding a little bit more of code.

i copy the final code, is a little bit bungler but works:

```
import clr

# Import RevitAPI
clr.AddReference("RevitAPI")
from Autodesk.Revit.DB import *

# Import DocumentManager and TransactionManager
clr.AddReference("RevitServices")
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager

doc = DocumentManager.Instance.CurrentDBDocument

pl = doc.FamilyManager.Parameters
s = doc.FamilyManager.CurrentType

mm=304.8
Name_Parameter = IN[0]

for p in pl:
	a = p.Definition.Name
	if a == Name_Parameter:
	
		paramType = p.Definition.ParameterType
		if paramType.ToString() == "Length":
			OUT = s.AsDouble(p)*mm
		else:
			OUT = s.AsString(p)

```

Thanks all for your ideas and your time

---

<div class="post-metadata">

**Author:** ![Mostafa\_El\_Ayoubi](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/mostafa_el_ayoubi/32/7815_2.png) [@Mostafa\_El\_Ayoubi](https://forum.dynamobim.com/u/Mostafa_El_Ayoubi)\
**Post date:** [December 29, 2016, 8:24pm UTC](https://forum.dynamobim.com/t/revit-family-parameters-value-family-editor/8499/7 "2016-12-29T20:24:04Z")

</div>

My bad @Raul.Galdran , when the parameter type is not right for the query method, I thought it would return an exception but it just returns “None”…  
So here’s an alternative to make sure all parameter types are handeled :

 ![](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/8/1/81effa696274e6ce1328d9c73700c5f947a5fd20.png)

```
import clr

# Import RevitAPI
clr.AddReference('RevitAPI')
from Autodesk.Revit.DB import *

# Import DocumentManager and TransactionManager
clr.AddReference('RevitServices')
import RevitServices
from RevitServices.Persistence import DocumentManager

doc = DocumentManager.Instance.CurrentDBDocument

s = doc.FamilyManager.CurrentType

pl = doc.FamilyManager.Parameters

Name_Parameter = IN[0]

p = [i for i in pl if i.Definition.Name == Name_Parameter][0]
UIunits = p.DisplayUnitType
vals = s.AsString(p), UnitUtils.ConvertFromInternalUnits(s.AsDouble(p),UIunits), s.AsInteger(p)
v = [v for v in vals if v != None]

OUT = v

```

I also added some code to get the current UI units in your family document and do the convetion automatically. That way all units will be handeled automatically.

---

<div class="post-metadata">

**Author:** ![Raul.Galdran](https://avatars.discourse-cdn.com/v4/letter/r/7feea3/32.png) [@Raul.Galdran](https://forum.dynamobim.com/u/Raul.Galdran)\
**Post date:** [December 30, 2016, 12:28pm UTC](https://forum.dynamobim.com/t/revit-family-parameters-value-family-editor/8499/8 "2016-12-30T12:28:26Z")

</div>

@Mostafa_El_Ayoubi

I tried your last code and still doesn’t read text neither integer. I’ve modified " in a really crappy way" but now works with every Parameter Type i’ve tried. ( Text, integer, number, area, length, and several units more), all returned the value from the parameter.

The problem was (UIunits = p.DisplayUnitType) in text/integer…!

I copy the final code:

```
import clr

# Import RevitAPI
clr.AddReference('RevitAPI')
from Autodesk.Revit.DB import *

# Import DocumentManager and TransactionManager
clr.AddReference('RevitServices')
import RevitServices
from RevitServices.Persistence import DocumentManager

doc = DocumentManager.Instance.CurrentDBDocument

s = doc.FamilyManager.CurrentType

pl = doc.FamilyManager.Parameters

Name_Parameter = IN[0]

p = [i for i in pl if i.Definition.Name == Name_Parameter][0]

try: 
	UIunits = p.DisplayUnitType
	vals = UnitUtils.ConvertFromInternalUnits(s.AsDouble(p),UIunits), s.AsInteger(p)
	v = [v for v in vals if v != None][0]

	OUT = v
except Exception:
	
	vals = s.AsString(p), s.AsInteger(p)
	v = [v for v in vals if v != None][0]

	OUT = v

```

Thanks again for your time and solutions
