Retrieve Dimension Style by name using python

Retrieve Dimension Style by name using python

lucas-gsbp
Contributor Contributor
1,691 Views
8 Replies
Message 1 of 9

Retrieve Dimension Style by name using python

lucas-gsbp
Contributor
Contributor

Hi, I am trying to collect a certain dimension style by name.

 

dTypes = FilteredElementCollector(doc).OfClass(DimensionType)

dimensionTypes = []
for i in dTypes:
	dimensionTypes.append(i.Name)

But I am getting an error "AttributeError: Name"

According to the Revit API Docs:

https://www.revitapidocs.com/2019/a6f6655d-3383-a0ea-670d-0bbe6d2bb964.htm

 

Name is a property of the Dimension Style Class.

 

Using PyRevit.

 

Thanks!

0 Likes
Accepted solutions (1)
1,692 Views
8 Replies
Replies (8)
Message 2 of 9

Yien_Chao
Advisor
Advisor
Accepted solution

every type is a Symbol in API.

so use : i.get_Parameter(BuiltInParameter.SYMBOL_NAME_PARAM).AsString()

0 Likes
Message 3 of 9

Yien_Chao
Advisor
Advisor

I meant  type from system famillies.

0 Likes
Message 4 of 9

lucas-gsbp
Contributor
Contributor

It worked, indeed but would you happen to know why it works for C# and not python?

Why python can't read the name property of this particular class?

0 Likes
Message 5 of 9

Yien_Chao
Advisor
Advisor

Does .Name attribute  works with C# ?

0 Likes
Message 6 of 9

lucas-gsbp
Contributor
Contributor

Well at least for me it did. I am not sure why it wouldn't work.

0 Likes
Message 7 of 9

Yien_Chao
Advisor
Advisor

https://www.revitapidocs.com/2018.2/8757156f-79ec-fdff-e74d-7c86e576b73e.htm

the .FamilyName seems to work fine, but the .Name is use to Set, not to get.

0 Likes
Message 8 of 9

lucas-gsbp
Contributor
Contributor

You are correct. I went and Checked I did use the FamilyName property.

The problem lied on the fact that using python would return the system family name and using C# I would get the dimension style Name.

0 Likes
Message 9 of 9

Yien_Chao
Advisor
Advisor

on the other hand, you can use .Name attribute with Revit FamilyInstance and Element.

i guess the attribute is not used for the same reason on ElementType, because if just for setting.