# Get parameter value with python

**URL:** <https://forum.dynamobim.com/t/get-parameter-value-with-python/42234>\
**Category:** Revit\
**Tags:** python, dynamo\
**Created:** [October 23, 2019, 12:01pm UTC](https://forum.dynamobim.com/t/get-parameter-value-with-python/42234 "2019-10-23T12:01:23Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![The\_Kostik](https://avatars.discourse-cdn.com/v4/letter/t/74df32/32.png) [@The\_Kostik](https://forum.dynamobim.com/u/The_Kostik)\
**Post date:** [October 23, 2019, 12:01pm UTC](https://forum.dynamobim.com/t/get-parameter-value-with-python/42234/1 "2019-10-23T12:01:23Z")

</div>

Hello everyone!

I need some help with getting values of elements. I wrote python code in dynamo to collect the value of highlighted parameter:  
 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/e/3/e33ed6a590d0e8080090e2055f00d4a322cd4422.png)

I used dynamo nodes for sorting data:

 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/8/3/8344e081908d6bce88badf6774c350c33229c1ca.png)

And here is the code of python script:

 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/7/f/7f4e5206f9338bb1e7e32c1b10fe71643db459e0.png)

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

import System
from System.Collections.Generic import List

clr.AddReference('RevitNodes')
import Revit
clr.ImportExtensions(Revit.Elements)
clr.ImportExtensions(Revit.GeometryConversion)

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

doc = IN[0]
element = UnwrapElement(IN[1])

# First method
name = []
value = []
DB = element.GetParameters("Марка")
for i in DB:
	name.append(i.Definition.Name)
	value.append(i.AsValueString())

# Second method
# DB = element.get_Parameter(BuiltInParameter.ALL_MODEL_MARK)
# name = DB.Definition.Name
# value = DB.AsValueString()

OUT = name, value, DB

```

The result of my script is null:  
 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/a/3/a36705f7090151b68f19d6e6d38849db4960cb42.png)

What i’m doing wrong?

---

<div class="post-metadata">

**Author:** ![Thomas\_Corrie](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/thomas_corrie/32/63060_2.png) [@Thomas\_Corrie](https://forum.dynamobim.com/u/Thomas_Corrie)\
**Post date:** [October 23, 2019, 1:17pm UTC](https://forum.dynamobim.com/t/get-parameter-value-with-python/42234/2 "2019-10-23T13:17:51Z")

</div>

What storage type is the parameter Марка? Is it equivalent to Mark? If so, the storage type is Text (string) and if you query it with `AsValueString()` it will return null. Try with `AsString()` instead

 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/b/3/b30e586c6961aa00b03335319dbfa74c5f9a2420.png)

---

<div class="post-metadata">

**Author:** ![The\_Kostik](https://avatars.discourse-cdn.com/v4/letter/t/74df32/32.png) [@The\_Kostik](https://forum.dynamobim.com/u/The_Kostik)\
**Post date:** [October 23, 2019, 1:52pm UTC](https://forum.dynamobim.com/t/get-parameter-value-with-python/42234/3 "2019-10-23T13:52:42Z")

</div>

Yes, it’s equivalent to Mark. Thank you Thomas! It works!  
May be there is a simple way to find out what storage type of each parameter of the element?

---

<div class="post-metadata">

**Author:** ![Thomas\_Corrie](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/thomas_corrie/32/63060_2.png) [@Thomas\_Corrie](https://forum.dynamobim.com/u/Thomas_Corrie)\
**Post date:** [October 23, 2019, 2:01pm UTC](https://forum.dynamobim.com/t/get-parameter-value-with-python/42234/4 "2019-10-23T14:01:28Z")

</div>

I use the [Revit Lookup](https://github.com/jeremytammik/RevitLookup) addin to inspect parameters. You can get the latest version from [lookupbuilds.com](https://lookupbuilds.com/index.html?prefix=releases/). It gives you lots of information:

 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/b/e/be58d309b8f333a86d6db9084b2b0f151a6a07a1.png)

---

<div class="post-metadata">

**Author:** ![yongsuk](https://avatars.discourse-cdn.com/v4/letter/y/e36b37/32.png) [@yongsuk](https://forum.dynamobim.com/u/yongsuk)\
**Post date:** [March 3, 2020, 12:42pm UTC](https://forum.dynamobim.com/t/get-parameter-value-with-python/42234/5 "2020-03-03T12:42:36Z")

</div>

Excuse me, let me ask you a question.  
Only one element may be used for the above results.  
Is there a way to get multiple factors?

---

<div class="post-metadata">

**Author:** ![Thomas\_Corrie](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/thomas_corrie/32/63060_2.png) [@Thomas\_Corrie](https://forum.dynamobim.com/u/Thomas_Corrie)\
**Post date:** [March 3, 2020, 2:14pm UTC](https://forum.dynamobim.com/t/get-parameter-value-with-python/42234/6 "2020-03-03T14:14:37Z")

</div>

You can put it within a loop

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

---

<div class="post-metadata">

**Author:** ![yongsuk](https://avatars.discourse-cdn.com/v4/letter/y/e36b37/32.png) [@yongsuk](https://forum.dynamobim.com/u/yongsuk)\
**Post date:** [March 4, 2020, 10:15am UTC](https://forum.dynamobim.com/t/get-parameter-value-with-python/42234/7 "2020-03-04T10:15:02Z")

</div>

Thank you very much :\>

---

<div class="post-metadata">

**Author:** ![michelle.mackD3WWQ](https://avatars.discourse-cdn.com/v4/letter/m/9f8e36/32.png) [@michelle.mackD3WWQ](https://forum.dynamobim.com/u/michelle.mackD3WWQ)\
**Post date:** [November 16, 2020, 10:41pm UTC](https://forum.dynamobim.com/t/get-parameter-value-with-python/42234/8 "2020-11-16T22:41:47Z")

</div>

hello, I’d like to do the same thing as above, but with more than one parameter. How would I do multiple parameters within an element? Thanks!

---

<div class="post-metadata">

**Author:** ![dfgind](https://avatars.discourse-cdn.com/v4/letter/d/85f322/32.png) [@dfgind](https://forum.dynamobim.com/u/dfgind)\
**Post date:** [April 7, 2021, 7:07am UTC](https://forum.dynamobim.com/t/get-parameter-value-with-python/42234/9 "2021-04-07T07:07:05Z")

</div>

I copied the code exactly and tried this solution (“AsString()”) however is not working for me.

I am trying to read the value of a shared parameter…maybe this is the reason why this doesnt work. You tried it with values of family parameters, didnt you?

---

<div class="post-metadata">

**Author:** ![Thomas\_Corrie](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/thomas_corrie/32/63060_2.png) [@Thomas\_Corrie](https://forum.dynamobim.com/u/Thomas_Corrie)\
**Post date:** [April 7, 2021, 9:53pm UTC](https://forum.dynamobim.com/t/get-parameter-value-with-python/42234/10 "2021-04-07T21:53:57Z")

</div>

What sort of storage type is your shared parameter? AsString() is only appropriate if your parameter is text (string). If it is numeric then AsInteger() or AsDouble() or AsValueString() would be what is needed. You can see the descriptions of these methods here: [Parameter Methods](https://www.revitapidocs.com/2021.1/0b04b80d-b318-986e-48cc-835d0dda76e5.htm)

The original query was for the built-in parameter Mark which is stored as a string. But whether it is a built-in, family, project or shared parameter doesn’t make any difference to retrieiving the value.

---

<div class="post-metadata">

**Author:** ![Ewan\_Opie](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/ewan_opie/32/77070_2.png) [@Ewan\_Opie](https://forum.dynamobim.com/u/Ewan_Opie)\
**Post date:** [April 9, 2021, 2:42am UTC](https://forum.dynamobim.com/t/get-parameter-value-with-python/42234/11 "2021-04-09T02:42:50Z")

</div>

Here is a bit of code that hopefully can guide you on your way @dfgind

 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/3/9/39fe0765c59a1f821305d9663aa2db26bb4d6178.png)

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

import System
from System.Collections.Generic import List

clr.AddReference('RevitNodes')
import Revit
clr.ImportExtensions(Revit.Elements)
clr.ImportExtensions(Revit.GeometryConversion)

clr.AddReference('RevitServices')
import RevitServices
from RevitServices.Persistence import DocumentManager

doc = DocumentManager.Instance.CurrentDBDocument

def tolist(obj1):
	if hasattr(obj1," __iter__"): return obj1
	else: return [obj1]

def getParam(element,param):
	value = []
	try:
		DB = element.GetParameters(param)
		for i in DB:
			if "Double" in str(i.StorageType): 
				# Metric Converstion
				value.append(i.AsDouble()*304.8)
			elif "Integer" in str(i.StorageType):
				value.append(i.AsInteger())
			elif "String" in str(i.StorageType):
				value.append(i.AsString())
			else:
				elemId =i.AsElementId()
				value.append(doc.GetElement(elemId))
	except:
		pass
	return value

input = tolist(IN[0])
params = IN[1]
result = []

# Get parameters for Multiple Elements
for i in input:
	pack = []
	for p in params:
		elem = UnwrapElement(i)
		pack.append(getParam(elem,p))
	result.append(pack)

OUT = result
```
