我不知道这是 IronPython 问题、Revit API 程序集问题还是其他问题。任何可能导致这种情况的信息/想法都值得赞赏。
我知道这可以通过再次重新导入相同的命名空间来解决,但我很想知道为什么会这样。
以下是正在发生的事情的简短示例。图像显示 RevitPythonShell 控制台输出。
文件1.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
文件2.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