.NET Assembly loses some methods when imported from one Python file into another (IronPython)
Asked Answered
F

0

6

I have no idea, if this is a IronPython issue, a Revit API assembly issue, or something else. Any information/ideas on what could be causing this is appreciated.

I understand this is solvable by re-importing the same namespace again, but I am dying to understand why that is.

Below is short example of what is happening. Images show RevitPythonShell Console output.

File1.py

import clr
clr.AddReference('RevitAPI')      # Contains Imports Autodesk.Revit.DB
from Autodesk.Revit import DB     # OK
DB.Element.Name                   # OK
DB.Element.Name.GetValue()        # OK: Method exists. As Expected

File2.py

from File1 import DB
DB.Element.Name                   # OK, Property Exists
DB.Element.Name.GetValue()        # *** Method DOES NOT Exist, Attribute Error is raised
from Autodesk.Revit import DB     # Re-import the same namespace again
DB.Element.Name.GetValue()        # OK:  Method Exists 

enter image description here

enter image description here

Face answered 14/11, 2016 at 0:51 Comment(5)
can you quickly check the line from File2 import DB in the file File2.py? That could be your problem right there... but also could just be you typing it wrong into SO...Eohippus
Thanks Daren. Apologies, that was just a typo in the example. The file1 is being imported properly.Face
OK. I can reproduce this. It is really very interesting. I too have no idea what is going on here...Eohippus
Filed as a bug, I will post back if I get an answer from the maintainers: github.com/IronLanguages/main/issues/1540Face
New issue url: github.com/IronLanguages/ironpython2/issues/…Face

© 2022 - 2024 — McMap. All rights reserved.