Create detail curve error

Hi,
I am learning python and python in dynamo, in this script i am trying to create a new DetailCurve in Revit using a line I have created in Dynamo and a View as an input to the Python node.
it gives me error, can someone explains why ?
thanks
image

import clr
clr.AddReference('RevitAPI')
from Autodesk.Revit.DB import *

clr.AddReference("RevitServices")
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager

def NewDetailCurve(view, curve):
	try:
		NewDetailCurve = doc.Create.NewDetailCurve(view, curve)
		NewDetailCurve.View = view
		NewDetailCurve.Curve = curve
		return NewDetailCurve
	except: return None

doc = DocumentManager.Instance.CurrentDBDocument
view = UnwrapElement(IN[0])
curve = UnwrapElement(IN[1])

TransactionManager.Instance.EnsureInTransaction(doc)
if isinstance(IN[0], list) and isinstance(IN[1], list): OUT = [NewDetailCurve(x, y) for x, y in zip(IN[0], IN[1])]
else: OUT = None
TransactionManager.Instance.TransactionTaskDone()
  1. Try removing the Try:Except from the definition, or modify it to return the error via traceback. You are suppressing valuable information when the function fails by forcing a none result.

  2. Instead of wrapping your function inside the check for lists inside the if statement, check if the data is a list, and if not wrap the results in a list. It will be an extra two lines of code but shouldn’t delay anything. By doing it this way and returning “none” you are once again hiding valuable information, and the combination of matching results further masks the failure point.

  3. I am not sure you are gaining anything by defining a function here, rather than running each line by itself. Again - a valuable failure message could be suppressed as is.

@TaraPD
there are no errors in your code
the script runs as requested

2 Likes