# Get Parameters in Python Script

**URL:** <https://forum.dynamobim.com/t/get-parameters-in-python-script/70742>\
**Category:** Revit\
**Tags:** python\
**Created:** [November 25, 2021, 3:32am UTC](https://forum.dynamobim.com/t/get-parameters-in-python-script/70742 "2021-11-25T03:32:22Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Austin21](https://avatars.discourse-cdn.com/v4/letter/a/df705f/32.png) [@Austin21](https://forum.dynamobim.com/u/Austin21)\
**Post date:** [November 25, 2021, 3:32am UTC](https://forum.dynamobim.com/t/get-parameters-in-python-script/70742/1 "2021-11-25T03:32:22Z")

</div>

Hello,

I am trying to get parameter value for the width of ducts using Python script, I find some examples in the web:

```auto
duct = UnwrapElement(IN[0])
out1 = []

for d in duct:
	dlevel = d.GetParameters("Width")
	out1.append(dlevel.AsValueString())

#OUT = out1

```

However, the dlevel is a list it self and I need to add a code in order to work. Otherwise, it retruns errors.

![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/4/5/451ef9d6d2337b37c46b70aacecbe39775ea7d03.png)

```auto
for d1 in dlevel:

```

My final code is like the below

```auto
duct = UnwrapElement(IN[0])
out1 = []

for d in duct:
	dlevel = d.GetParameters("Width")
	for d1 in dlevel:
		out1.append(d1.AsValueString())

#OUT = out1

```

Does my code correct or Am I miss something?

Thanks.

---

<div class="post-metadata">

**Author:** ![chuongmep](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/chuongmep/32/197537_2.png) [@chuongmep](https://forum.dynamobim.com/u/chuongmep)\
**Post date:** [November 25, 2021, 3:45am UTC](https://forum.dynamobim.com/t/get-parameters-in-python-script/70742/2 "2021-11-25T03:45:34Z")

</div>

Something like that if you want to get width of duct

```auto
def tolist(obj1):
	if hasattr(obj1,' __iter__') : return obj1
	else : return [obj1]
#Preparing input from dynamo to revit
duct = UnwrapElement(tolist(IN[0]))
out1 = []
for d in duct:
	value = d.get_Parameter(BuiltInParameter.RBS_CURVE_WIDTH_PARAM).AsValueString()
	out1.append(value)

OUT = out1

```

or use GetPrameters :

```auto
def tolist(obj1):
	if hasattr(obj1,' __iter__') : return obj1
	else : return [obj1]
#Preparing input from dynamo to revit
ducts = UnwrapElement(tolist(IN[0]))

out1 = []

for d in ducts:
	pras = d.GetParameters("Width")
	for p in pras:
		out1.append(p.AsValueString())

OUT = out1

```

---

<div class="post-metadata">

**Author:** ![Austin21](https://avatars.discourse-cdn.com/v4/letter/a/df705f/32.png) [@Austin21](https://forum.dynamobim.com/u/Austin21)\
**Post date:** [November 25, 2021, 6:53am UTC](https://forum.dynamobim.com/t/get-parameters-in-python-script/70742/3 "2021-11-25T06:53:32Z")

</div>

One more question. I use AsDouble and it returns 1. Is there any method to get the value in double or integer other than sort it out after using AsValueString()?

---

<div class="post-metadata">

**Author:** ![chuongmep](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/chuongmep/32/197537_2.png) [@chuongmep](https://forum.dynamobim.com/u/chuongmep)\
**Post date:** [November 25, 2021, 7:02am UTC](https://forum.dynamobim.com/t/get-parameters-in-python-script/70742/4 "2021-11-25T07:02:52Z")

</div>

Can, you can custom by function, like that

```auto
def GetParameterValue(parameter):
  value= None
  if parameter.StorageType == StorageType.Double:
    value = parameter.AsDouble()
  elif parameter.StorageType == StorageType.Integer:
    if parameter.Definition.ParameterType == ParameterType.Integer:
      value = parameter.AsInteger()
    else:
      value = parameter.AsValueString()
  elif parameter.StorageType == StorageType.String:
    value = parameter.AsString()
  elif parameter.StorageType == StorageType.ElementId:
    value = parameter.AsElementId()
  return value

```

---

<div class="post-metadata">

**Author:** ![Austin21](https://avatars.discourse-cdn.com/v4/letter/a/df705f/32.png) [@Austin21](https://forum.dynamobim.com/u/Austin21)\
**Post date:** [November 25, 2021, 7:10am UTC](https://forum.dynamobim.com/t/get-parameters-in-python-script/70742/5 "2021-11-25T07:10:11Z")

</div>

Sorry for my missing presentation. My question is that the duct width is 305mm, however it return to 1 if using AsDouble().  
 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/3/9/3967436bbe69933cbaa33de2d5e92ed9875042ef.png)

Is that I have to write a small function to remove the unit from AsValuString() in order to return 305?

Thanks for your reply.

---

<div class="post-metadata">

**Author:** ![chuongmep](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/chuongmep/32/197537_2.png) [@chuongmep](https://forum.dynamobim.com/u/chuongmep)\
**Post date:** [November 25, 2021, 7:48am UTC](https://forum.dynamobim.com/t/get-parameters-in-python-script/70742/6 "2021-11-25T07:48:49Z")

</div>

The number 1 I guess is the unit of feet : 1feet = 304.8 mm =\> AsvalueString can become 305mm

---

<div class="post-metadata">

**Author:** ![Austin21](https://avatars.discourse-cdn.com/v4/letter/a/df705f/32.png) [@Austin21](https://forum.dynamobim.com/u/Austin21)\
**Post date:** [November 25, 2021, 8:03am UTC](https://forum.dynamobim.com/t/get-parameters-in-python-script/70742/7 "2021-11-25T08:03:50Z")

</div>

I forget this. Thanks you so much.
