CLR in Python Script node create 3D splines with input points on the splines

Hi,
Trying to execute CLR NurbSpline.Create in a Python Script node.
I guess I am missing a reference to use system.collections.generic List of XYZ to pass to NurbSpline.Create.
Refer code below.
With run, it stops at NurbSpline.Create . But the problem is probably before that. The set of XYZ points must be a List class that is not referenced - yes?
Thanks for your patience,
K.

import sys
import clr

clr.AddReference('RevitAPI')
clr.AddReference('RevitAPIUI')
clr.AddReference('RevitServices')

from Autodesk.Revit.DB import *
from Autodesk.Revit.UI import *
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager

Cables = IN[0]
SPoints = []
elog = []

iX = Cables[0];
iY = Cables[1];
iZ = Cables[2];

for i in range(len(iX)):
    nL = []
    for j in range(len(iX[0])):
        p = XYZ(iX[i][j],iY[i][j],iZ[i][j])
        nL.append(p)
    SPoints.append(nL)

doc = DocumentManager.Instance.CurrentDBDocument

for PS in SPoints:
    TransactionManager.Instance.EnsureInTransaction(doc)
    spline = NurbSpline.Create(PS)
    sketchPlane = SketchPlane.Create(doc, Plane.CreateByNormalAndOrigin(XYZ.BasisZ, XYZ.Zero))
    modelCurve = doc.Create.NewModelCurve(spline, sketchPlane)    
    TransactionManager.Instance.TransactionTaskDone()

By the way … the input is ok … … similar code is working 100% in Civil 3D Dynamo - where ACAD Point3Dcollections are used to pass XYZ set to the spline creation method in a transaction.

I would suggest you have a look at the SDK at what the create method requires as part of the input.

This can be found here - NurbSpline Methods

It would seem you are missing a parts of the create requirements and the method to use will depend on what you have that can be utilised.

1 Like

Hi

NurbSpline.Create() takes a HermiteSpline as argument.

here the method to create HermiteSpline

1 Like

Thank You

Thx …

That solved it … thank you …
just need to fix the sketch plane now …
Exception … Curve must be in the Plane

for PS in SPoints:
    TransactionManager.Instance.EnsureInTransaction(doc)
    spline = HermiteSpline.Create(PS, False)
    sketchPlane = SketchPlane.Create(doc, Plane.CreateByNormalAndOrigin(XYZ.BasisZ, XYZ.Zero))
    modelCurve = doc.Create.NewModelCurve(spline, sketchPlane)    
    TransactionManager.Instance.TransactionTaskDone()