OUT shows null

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

import Revit

from Autodesk.Revit.DB import *
from Autodesk.Revit.DB.Mechanical import *

from Autodesk.Revit.Creation import *

from Revit.Elements import *

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 = []	


for i,j in zip(k,l):
		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)
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?

Probably to do with your lacing. Try set to longest.

Also, instead of appending None to Elements if there is an exception, try the following…

except Exception, ex:

This should help you understand where it is failing.

Hello @Alex_AT_UK
a few comments

  • missing import (ToDSType(bool) extension method)
  • to get current doc prefer use : doc = DocumentManager.Instance.CurrentDBDocument
  • need to UnwrapElement yours inputs to expose them at the Revit API (no need to convert Id)

read this :wink:

and if it’s possible avoid the try except (unless you have no other solution) :slight_smile:


Before diving in create your custom node, always make sure the python script works first the design graph environment.

Some errors i found while reading your python script:

  1. diameter is a number, not a string. So your ToString() of diameter will definition make your script fail.
  2. you did not import the extension of ToDSType(), so your script will fail as well

Some pointers:

  1. do not use try and except UNLESS you wanna raise your own exception to find out the exact root cause with your own warning message OR you really have no choice
  2. use UnwrapElement() extension method to retrieve Revit element from dynamo’s element instead of going one big round like what you did there.
  3. alway label your variable (be it abbr or short description). Its for better readability especially when you are asking the public for help :slight_smile: