I created a little script to transform 3D polylines of a CAD link to ducts:
The custom node looks like that:
I have the following code in the custom node:
import clr
clr.AddReference("RevitNodes")
import Revit
clr.AddReference('RevitAPI')
from Autodesk.Revit.DB import *
from Autodesk.Revit.DB.Mechanical import *
from Autodesk.Revit.Creation import *
clr.ImportExtensions(Revit.GeometryConversion)
from Revit.Elements import *
clr.AddReference("RevitServices")
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
import System
doc = IN[0]
l = IN[1]
k = IN[2]
ducttype = IN[3]
systemtype = IN[4]
level = IN[5]
diameter = IN[6]
elements = []
TransactionManager.Instance.EnsureInTransaction(doc)
for i,j in zip(k,l):
try:
x= i.ToXyz()
y= j.ToXyz()
duct = Duct.Create(doc, ElementId(systemtype.Id), ElementId(ducttype.Id), ElementId(level.Id), x, y)
param = duct.get_Parameter(BuiltInParameter.RBS_CURVE_DIAMETER_PARAM)
param.SetValueString(diameter.ToString())
elements.append(duct.ToDSType(False))
except:
elements.append(None)
TransactionManager.Instance.TransactionTaskDone()
OUT = elements
The nodes seem to be created for the ducts but for some reason the ducts itself do not get created. The output allways shows “NULL” as well.
Any idea why this could be the case?