我已经从博客中复制了发电机脚本,以便在revit中创建风管,但它无法运行。 enter image description here
我有没有错过任何愚蠢的事情?
答案 0 :(得分:0)
由于错过了依赖项导入,我遇到了类似的错误。我在尝试选择特定的DuctType时也遇到了错误,因此我将其留空并且Revit API为我们选择了第一个。我能够用类似的方法使它工作:
请参阅Dynamo文件:Dynamo Add Duct .dyn image
import clr
# Import RevitNodes
clr.AddReference("RevitNodes")
import Revit
#import Revit DB
clr.AddReference('RevitAPI')
from Autodesk.Revit.DB import *
#import Revit Creation where Create.Duct is
from Autodesk.Revit.Creation import *
clr.ImportExtensions(Revit.GeometryConversion)
# Import Revit elements
from Revit.Elements import *
# Import DocumentManager
clr.AddReference("RevitServices")
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
import System
#The inputs to this node will be stored as a list in the IN variables.
doc = IN[0]
x = IN[1].ToXyz()
y = IN[2].ToXyz()
ductType = IN[3]
#ductTypeUnwrapped = UnwrapElement(ductType) #not working
# Start Transaction
TransactionManager.Instance.EnsureInTransaction(doc)
doc.Create.NewDuct(x, y, ductType); #if DuctType is null then Revit picks first type.
# Stop Transaction
TransactionManager.Instance.TransactionTaskDone()
OUT = doc