当从一个 Python 文件导入到另一个文件 (IronPython) 时,.NET 程序集会丢失一些方法

gta*_*ico 6 ironpython revit-api revitpythonshell

我不知道这是 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
Run Code Online (Sandbox Code Playgroud)

文件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 
Run Code Online (Sandbox Code Playgroud)

在此处输入图片说明

在此处输入图片说明