access ID and Unique ID values for instance families using Python

access ID and Unique ID values for instance families using Python

studio-a-int
Advocate Advocate
1,355 Views
2 Replies
Message 1 of 3

access ID and Unique ID values for instance families using Python

studio-a-int
Advocate
Advocate

I'm trying to extract the values for  ID and Unique ID for Generic Models.

I select all the entities and unwrap via Python.

 

If I try:

 

I_D =[]
for i in gen_models:
    I_D.append(i.LookupParameter("Unique ID").AsString())

OUT = I_D

 

is giving me the error:

 

"

AttributeError: 'NoneType' object has no attribute 'AsString'

 

"

 

if I try:

 

OUT = UnwrapElement(gen_models).Parameters

 

I get the list with all parameters as "Autodesk.Revit.DB.Parameter"

 

How do I access the value for each parameter?

 

Help greatly appreciated!

 

0 Likes
Accepted solutions (1)
1,356 Views
2 Replies
Replies (2)
Message 2 of 3

jeremytammik
Autodesk
Autodesk
Accepted solution

This data is not stored in a parameter, but provided directly as Element properties.

 

The element id is retuned by the Id property, and the unique id by the UniqueId one.

 

Cheers,

 

Jeremy



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

Message 3 of 3

studio-a-int
Advocate
Advocate

Jeremy -

 

thanks for your reply.

 

Apologize for not posting earlier, I had family issues.

 

Using Python I can pull the Id and UniqueId using few lines, as in the below ex. for Conduits and Conduit Fittings.

 

Thanks for your help!

 

con = FilteredElementCollector(doc).OfCategory(BuiltInCategory.OST_Conduit).WhereElementIsNotElementType().ToElements()
con_fit = FilteredElementCollector(doc).OfCategory(BuiltInCategory.OST_ConduitFitting).WhereElementIsNotElementType().ToElements()
con_ID = [i.Id for i in con]
con_U_ID =[i.UniqueId for i in con]
con_fit_ID =[i.Id for i in con_fit]
con_fit_U_ID =[i.UniqueId for i in con_fit]

0 Likes