IronPython to Python3 - Error

IronPython to Python3 - Error

aaron_rumple
Enthusiast Enthusiast
604 Views
3 Replies
Message 1 of 4

IronPython to Python3 - Error

aaron_rumple
Enthusiast
Enthusiast
Where famsyb is FamilySymbol...
print(famsymb.Name) works fine in IornPython and CPython3
print(famsymb.Name) fails in IronPython and CPython3 with no Property - Attribute Error
 
print(Element.Name.GetValue(famsymb)) returns the family type name as expected in IronPython
 
print(Element.Name.GetValue(famsymb)) returns error: "
TypeError : instance property must be accessed through a class instance"
 
Trying to move everythong to CPython3 in Revit 2023. Any insight?
Accepted solutions (1)
605 Views
3 Replies
Replies (3)
Message 2 of 4

RPTHOMAS108
Mentor
Mentor

Only that there seems to be far too many versions of Python to keep track of.

 

What do you mean from below:

print(famsymb.Name) works fine in IornPython and CPython3
print(famsymb.Name) fails in IronPython and CPython3 with no Property - Attribute Error
 
The same thing works and doesn't work in the same two versions of the language?
 
FamilySymbol is inherited from ElementType
ElementType.Name is WriteOnly i.e. can't be read.

 

public override string Name { set; }

 

One level of inheritance back
Element.Name is Read/Write.

 

public virtual string Name { get; set; }

 

I don't know what any of that means to a dynamically typed language but is likely the cause. Otherwise I would have said don't cast Element to FamilySymbol to read name.
 
Can you do:

 

El = Element(famsymb)
print(El.Name)

 

Message 3 of 4

aaron_rumple
Enthusiast
Enthusiast

Python 3 is ver. 3.8.5 which is what ships with Revit's Dynamo and pyRevit. So current and Adsk "approved". IronPythin is the 2023 shipped version.

 

Output of 

print(Element.Name.GetValue(famsymb)) using IronPython yields the expected list of family types.
aaron_rumple_0-1674783616152.png

Using CPythi\on it just returns:

aaron_rumple_1-1674783737323.png

I can hack around it, but running through a collection of familysymbols is the most direct way of getting the family types from a FilteredElementCollector of OST_DetailComponets WhereElementIsElementType.


 

 



You can't cast a familysymbol to an element in CPython.


 

 

Message 4 of 4

aaron_rumple
Enthusiast
Enthusiast
Accepted solution
0 Likes