# Get Type Parameters using Python Script

**URL:** <https://forum.dynamobim.com/t/get-type-parameters-using-python-script/46392>\
**Category:** Revit\
**Tags:** python, dynamo\
**Created:** [February 5, 2020, 6:07pm UTC](https://forum.dynamobim.com/t/get-type-parameters-using-python-script/46392 "2020-02-05T18:07:57Z")\
**Posts on this page:** 16\
**Page:** 1

<div class="post-metadata">

**Author:** ![DavidMena](https://avatars.discourse-cdn.com/v4/letter/d/e495f1/32.png) [@DavidMena](https://forum.dynamobim.com/u/DavidMena)\
**Post date:** [February 5, 2020, 6:07pm UTC](https://forum.dynamobim.com/t/get-type-parameters-using-python-script/46392/1 "2020-02-05T18:07:57Z")

</div>

Hi everyone!  
Does anybody have an idea on how to get Type Parameters using Python Script. I don’t have any trouble getting instance parameters, but for Type Parameters I only get empty lists.  
I have a list of elements in the input and then iterate over them unwraping the elements so that I can use the GetParameters or LookupParameters method. What is missing?  
Thank You!

 ![TypeParameters](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/7/3/73bb8c760728ca69bcc0ff392861fa6acd4940f9.jpeg)

---

<div class="post-metadata">

**Author:** ![LievX](https://avatars.discourse-cdn.com/v4/letter/l/7ea924/32.png) [@LievX](https://forum.dynamobim.com/u/LievX)\
**Post date:** [February 5, 2020, 6:14pm UTC](https://forum.dynamobim.com/t/get-type-parameters-using-python-script/46392/2 "2020-02-05T18:14:26Z")

</div>

I don’t know anything about Python, but in Dyanmo you need to get the Element from the element, I mean, Get the Type of the element before reading the type parameters… I supose python should not be that different

---

<div class="post-metadata">

**Author:** ![DavidMena](https://avatars.discourse-cdn.com/v4/letter/d/e495f1/32.png) [@DavidMena](https://forum.dynamobim.com/u/DavidMena)\
**Post date:** [February 5, 2020, 6:24pm UTC](https://forum.dynamobim.com/t/get-type-parameters-using-python-script/46392/3 "2020-02-05T18:24:54Z")

</div>

I’ve tried to use GetType method and then iterate over the types, applying both GetParameters and LookupParameters methods but only get this Error Message: “AttributeError: ‘RuntimeType’ object has no attribute 'GetParameters”

 ![Description](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/a/2/a2b1f5c721c4d75f4ffe2da65c33102b94655d83.jpeg)

---

<div class="post-metadata">

**Author:** ![LievX](https://avatars.discourse-cdn.com/v4/letter/l/7ea924/32.png) [@LievX](https://forum.dynamobim.com/u/LievX)\
**Post date:** [February 5, 2020, 6:27pm UTC](https://forum.dynamobim.com/t/get-type-parameters-using-python-script/46392/4 "2020-02-05T18:27:59Z")

</div>

again, I have no idea of python yet, but have you tried “t.GetParameter” (without the final “s”)?

---

<div class="post-metadata">

**Author:** ![DavidMena](https://avatars.discourse-cdn.com/v4/letter/d/e495f1/32.png) [@DavidMena](https://forum.dynamobim.com/u/DavidMena)\
**Post date:** [February 5, 2020, 6:32pm UTC](https://forum.dynamobim.com/t/get-type-parameters-using-python-script/46392/5 "2020-02-05T18:32:47Z")

</div>

There is no “GetParamater” method in the RevitAPI. Anyways, thank you for taking your time in answering me and trying to help 🙂

---

<div class="post-metadata">

**Author:** ![cgartland](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/cgartland/32/45378_2.png) [@cgartland](https://forum.dynamobim.com/u/cgartland)\
**Post date:** [February 5, 2020, 7:29pm UTC](https://forum.dynamobim.com/t/get-type-parameters-using-python-script/46392/6 "2020-02-05T19:29:51Z")

</div>

**EDIT:** Added conditionals to account for null values

Hi David, try something like this:

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

doc = DocumentManager.Instance.CurrentDBDocument

elementos = UnwrapElement(IN[0])
descripciones = []

for elemento in elementos:
    # Get ElementId of ElementType
    tipo_id = elemento.GetTypeId()
    # Get actual Element from Document
    tipo = doc.GetElement(tipo_id)
    if tipo:
        parametro = tipo.LookupParameter('Description')
        if parametro:
            descripcion = parametro.AsString()
            descripciones.append(descripcion)
    else:
        descripciones.append('')

OUT = descripciones
```

---

<div class="post-metadata">

**Author:** ![DavidMena](https://avatars.discourse-cdn.com/v4/letter/d/e495f1/32.png) [@DavidMena](https://forum.dynamobim.com/u/DavidMena)\
**Post date:** [February 5, 2020, 8:06pm UTC](https://forum.dynamobim.com/t/get-type-parameters-using-python-script/46392/7 "2020-02-05T20:06:54Z")

</div>

@cgartland  
I tried your code but I don’t know why it returns this Error Message: “AttributeError: ‘NoneType’ object has no attribute 'LookupParameter”.  
I don’t know if it has something to do with the fact that the list in IN[0] is a list of elements retrieved from a linked model.

 ![01](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/f/6/f631077315b718801cbde04520c2f960f1efac39.jpeg)

---

<div class="post-metadata">

**Author:** ![Nico\_Stegeman](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/nico_stegeman/32/19204_2.png) [@Nico\_Stegeman](https://forum.dynamobim.com/u/Nico_Stegeman)\
**Post date:** [February 5, 2020, 8:10pm UTC](https://forum.dynamobim.com/t/get-type-parameters-using-python-script/46392/8 "2020-02-05T20:10:53Z")

</div>

This will get the Type Parameter Width from a Wall:

WallType = UnwrapElement(IN[0])

WidthWall = UnitUtils.ConvertFromInternalUnits(WallType.get\_Parameter(BuiltInParameter.WALL\_ATTR\_WIDTH\_PARAM).AsDouble(), unit)

---

<div class="post-metadata">

**Author:** ![DavidMena](https://avatars.discourse-cdn.com/v4/letter/d/e495f1/32.png) [@DavidMena](https://forum.dynamobim.com/u/DavidMena)\
**Post date:** [February 5, 2020, 8:16pm UTC](https://forum.dynamobim.com/t/get-type-parameters-using-python-script/46392/9 "2020-02-05T20:16:41Z")

</div>

@Nico_Stegeman  
I think “Description” is a string parameter which has no BuiltInParameter Enumeration 😕

---

<div class="post-metadata">

**Author:** ![c.poupin](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/c.poupin/32/89152_2.png) [@c.poupin](https://forum.dynamobim.com/u/c.poupin)\
**Post date:** [February 5, 2020, 8:49pm UTC](https://forum.dynamobim.com/t/get-type-parameters-using-python-script/46392/10 "2020-02-05T20:49:03Z")

</div>

Hello,  
you need get the document of the linkinstance

```
import clr

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

linkinstance = UnwrapElement(IN[0])
doclink = linkinstance.GetLinkDocument()
elementos = FilteredElementCollector(doclink).OfCategory(BuiltInCategory.OST_Roofs).WhereElementIsNotElementType().ToElements()

descripciones = []

for elemento in elementos:
    # Get ElementId of ElementType
    tipo_id = elemento.GetTypeId()
    # Get actual Element from Document
    tipo = doclink.GetElement(tipo_id)
    descripcion = tipo.LookupParameter('Description')
    descripciones.append(descripcion.AsString())

OUT = descripciones

```

 ![getlinkproperty](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/d/e/dec446d44bd850fc9f7fbd3fd2fb404acd98a231.jpeg)

for information GetType() is a [dotnet method](https://docs.microsoft.com/en-us/dotnet/api/system.object.gettype?view=netframework-4.8) not a RevitAPI method

---

<div class="post-metadata">

**Author:** ![DavidMena](https://avatars.discourse-cdn.com/v4/letter/d/e495f1/32.png) [@DavidMena](https://forum.dynamobim.com/u/DavidMena)\
**Post date:** [February 5, 2020, 10:11pm UTC](https://forum.dynamobim.com/t/get-type-parameters-using-python-script/46392/11 "2020-02-05T22:11:16Z")

</div>

@c.poupin  
That’s very helpful. Also I’ve managed to freely change the category of the elements.  
Now the issue is that I actually have several link instances as you can see in the image.  
How do you iterate over the list of links relating them with the list of elements extracted from the links? 😮

 ![category](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/4/c/4cde2d0c4d567792b3efacbfc3b88149c5abb8d2.jpeg)

---

<div class="post-metadata">

**Author:** ![c.poupin](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/c.poupin/32/89152_2.png) [@c.poupin](https://forum.dynamobim.com/u/c.poupin)\
**Post date:** [February 6, 2020, 8:46am UTC](https://forum.dynamobim.com/t/get-type-parameters-using-python-script/46392/12 "2020-02-06T08:46:58Z")

</div>

@DavidMena try this

```
import clr

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

import System
from System.Collections.Generic import *

linkRvt = UnwrapElement(IN[0])
category = UnwrapElement(IN[1])

bip = System.Enum.ToObject(BuiltInCategory, category.Id.IntegerValue)

if not hasattr(linkRvt, ' __iter__'):
	linkRvt = [linkRvt]

descripciones = []
for link in linkRvt:
	if not "ifc" in link.Name:
		doclink = link.GetLinkDocument()
		elementos = FilteredElementCollector(doclink).OfCategoryId(category.Id).WhereElementIsNotElementType().ToElements()
		#or 
		elementos = FilteredElementCollector(doclink).OfCategory(bip).WhereElementIsNotElementType().ToElements()
		
		for elem in elementos:
			elemType = doclink.GetElement(elem.GetTypeId())
			descripcion = elemType.get_Parameter(BuiltInParameter.ALL_MODEL_DESCRIPTION)
			descripciones.append(descripcion.AsString())    

OUT = descripciones

```

 ![RVT check](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/c/b/cb548124e3a5c19adb330114c45c93ffd023cbe6.jpeg)

---

<div class="post-metadata">

**Author:** ![DavidMena](https://avatars.discourse-cdn.com/v4/letter/d/e495f1/32.png) [@DavidMena](https://forum.dynamobim.com/u/DavidMena)\
**Post date:** [February 6, 2020, 6:46pm UTC](https://forum.dynamobim.com/t/get-type-parameters-using-python-script/46392/13 "2020-02-06T18:46:16Z")

</div>

@c.poupin  
Excellent! It worked absolutely great. I made some modifications to your code in order to obtain a parameter that is Shared Parameter instead of BuiltIn Parameter. But it gave me a starting point and a lot of light about this ‘extraction of parameters inside links’ issue.  
Again, Thank You guys!

 ![parameters](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/3/8/387a2e816309e9d7bdc372253c21c28855d8c24f.jpeg)

---

<div class="post-metadata">

**Author:** ![Ramyaa](https://avatars.discourse-cdn.com/v4/letter/r/4af34b/32.png) [@Ramyaa](https://forum.dynamobim.com/u/Ramyaa)\
**Post date:** [March 1, 2023, 7:10am UTC](https://forum.dynamobim.com/t/get-type-parameters-using-python-script/46392/14 "2023-03-01T07:10:10Z")

</div>

Hi @c.poupin, I have similar set of codes with different functionality which is returning null list. Could you please have a look.

```auto
import System
import sys
import clr

clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *
from System.Collections.Generic import *

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

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

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

clr.AddReference('DSCoreNodes')
from DSCore import *

# Get doc, uiapp and app
doc = DocumentManager.Instance.CurrentDBDocument
uiapp = DocumentManager.Instance.CurrentUIApplication
app = uiapp.Application

# input .rfa file paths
RFAfilepaths = UnwrapElement(IN[0])
# Input .sat file paths
SATfilepaths = UnwrapElement(IN[1])
SATfilepaths_name = [i[:-4] for i in SATfilepaths]

# SAT Import options
SAT_IOption = SATImportOptions()
SAT_IOption.VisibleLayersOnly = True
SAT_IOption.Placement = ImportPlacement.Origin
SAT_IOption.ColorMode = ImportColorMode.Preserved
SAT_IOption.Unit = ImportUnit.Default
# Save as options
Save_Option = SaveAsOptions()
Save_Option.OverwriteExistingFile = True
Save_Option.Compact = True
Save_Option.MaximumBackups = 1

TransactionManager.Instance.ForceCloseTransaction()

# list of updated .rfa files
updated = []

for RFAfilepath in RFAfilepaths:
	RFAfilepath_name = RFAfilepath[:-4]
	if RFAfilepath_name in SATfilepaths_name:
		# Find corresponding SAT filepath
		SATfilepath = SATfilepaths[SATfilepaths_name.index(RFAfilepath_name)]

		# Open .rfa file
		RFAopen = app.OpenDocumentFile(RFAfilepath)

		# Start transaction
		trans = Transaction(RFAopen, RFAfilepath_name)
		trans.Start()

		# Get all elements from open .rfa document
		collector = FilteredElementCollector(RFAopen)

		# delete existing elements
		allElements = collector.OfCategory(BuiltInCategory.OST_GenericModel).ToElements()
		for i in allElements:
			RFAopen.Delete(i.Id)

		# Import .sat file
		#RFAopen.Import(SATfilepath, SAT_IOption, view)
		shapeImporter = ShapeImporter()
		shapeImporter.InputFormat = ShapeImporterSourceFormat.SAT
		shapes = shapeImporter.Convert(RFAopen, SATfilepath)
		dsImportedSat = DirectShape.CreateElement(RFAopen, ElementId(BuiltInCategory.OST_GenericModel))
		dsImportedSat.SetShape(shapes)

		# Commit transaction changes
		trans.Commit()
		trans.Dispose()

		# Save .rfa file
		RFAopen.SaveAs(RFAfilepath, Save_Option)
		RFAopen.Close(False)
		updated.append(RFAfilepath)

#Save resulting Revit file to the destination path:
OUT = updated;

```

---

<div class="post-metadata">

**Author:** ![GavinNicholls](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/gavinnicholls/32/190442_2.png) [@GavinNicholls](https://forum.dynamobim.com/u/GavinNicholls)\
**Post date:** [March 1, 2023, 7:34am UTC](https://forum.dynamobim.com/t/get-type-parameters-using-python-script/46392/15 "2023-03-01T07:34:51Z")

</div>

Start a new topic, this code is not the same.

---

<div class="post-metadata">

**Author:** ![GavinNicholls](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/gavinnicholls/32/190442_2.png) [@GavinNicholls](https://forum.dynamobim.com/u/GavinNicholls)\
**Post date:** [March 1, 2023, 7:35am UTC](https://forum.dynamobim.com/t/get-type-parameters-using-python-script/46392/16 "2023-03-01T07:35:04Z")

</div>


