Hi everyone. I’ve created a NURBSCurve in Dynamo by control points, weights and knots.
Could you tell me why I cannot see it in Revit? Please find attached my file. I’m on the conceptual mass environment
Test1.dyn (44.6 KB)
Hi everyone. I’ve created a NURBSCurve in Dynamo by control points, weights and knots.
Could you tell me why I cannot see it in Revit? Please find attached my file. I’m on the conceptual mass environment
Test1.dyn (44.6 KB)
Can’t read your nodes, so please post an image export of your graph after zooming in so they are legible. It’s the camera icon in the upper left of the workspace.
Likely you are seeing one of the following:
I’ve tried two different creation methods from the API (this and this) with seemingly positive outputs, but neither create any actual geometry
And even if these worked, they wouldn’t do you much good, since they only work in the project environment.
I did a quick browse through the family creation part of the API, and it looks like the only option is to create a CurveByPoints()
. I’m no expert on geometry, but I do not believe that is what you are after. It did yield geometry in the mass environment though:
import clr
import System
#Import the Revit API
clr.AddReference('RevitAPI')
import Autodesk
from Autodesk.Revit.DB import *
#Import generic collections
clr.AddReference('System')
from System.Collections.Generic import *
#Import DocumentManager and TransactionManager
clr.AddReference('RevitServices')
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
#Import ToDSType(bool) extensions method
clr.AddReference('RevitNodes')
import Revit
clr.ImportExtensions(Revit.Elements)
clr.ImportExtensions(Revit.GeometryConversion)
#Reference the active Document and application
doc = DocumentManager.Instance.CurrentDBDocument
#---###Start scripting here:###---#
pts = [i.ToXyz() for i in IN[0]]
rpa = ReferencePointArray()
#Transaction start:
TransactionManager.Instance.EnsureInTransaction(doc)
for i in pts:
rp = doc.FamilyCreate.NewReferencePoint(i)
rpa.Append(rp)
curve = doc.FamilyCreate.NewCurveByPoints(rpa).ToDSType(False)
#Transaction end:
TransactionManager.Instance.TransactionTaskDone()
OUT = curve
I also had to scale your values with a factor 100, since if working with millimeters, your values are extremely small
The content of the two python scripts that didn’t work for me is below, if anyone wants to have a go:
import clr
import System
#Import the Revit API
clr.AddReference('RevitAPI')
import Autodesk
from Autodesk.Revit.DB import *
#Import generic collections
clr.AddReference('System')
from System.Collections.Generic import *
#Import DocumentManager and TransactionManager
clr.AddReference('RevitServices')
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
#Import ToDSType(bool) extensions method
clr.AddReference('RevitNodes')
import Revit
clr.ImportExtensions(Revit.Elements)
clr.ImportExtensions(Revit.GeometryConversion)
#Reference the active Document and application
doc = DocumentManager.Instance.CurrentDBDocument
#---###Start scripting here:###---#
pts = [i.ToXyz() for i in IN[0]]
iPts = List[XYZ]()
for i in pts:
iPts.Add(i)
weights = List[System.Double]()
for i in IN[1]:
weights.Add(i)
#Transaction start:
TransactionManager.Instance.EnsureInTransaction(doc)
Hspline = Autodesk.Revit.DB.HermiteSpline.Create(iPts, False)
Nspline = Autodesk.Revit.DB.NurbSpline.Create(Hspline)
#Transaction end:
TransactionManager.Instance.TransactionTaskDone()
OUT = Nspline
The second attempt:
import clr
import System
#Import the Revit API
clr.AddReference('RevitAPI')
import Autodesk
from Autodesk.Revit.DB import *
#Import generic collections
clr.AddReference('System')
from System.Collections.Generic import *
#Import DocumentManager and TransactionManager
clr.AddReference('RevitServices')
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
#Import ToDSType(bool) extensions method
clr.AddReference('RevitNodes')
import Revit
clr.ImportExtensions(Revit.Elements)
clr.ImportExtensions(Revit.GeometryConversion)
#Reference the active Document and application
doc = DocumentManager.Instance.CurrentDBDocument
#---###Start scripting here:###---#
pts = [i.ToXyz() for i in IN[0]]
iPts = List[XYZ]()
for i in pts:
iPts.Add(i)
weights = List[System.Double]()
for i in IN[1]:
weights.Add(i)
#Transaction start:
TransactionManager.Instance.EnsureInTransaction(doc)
spline = NurbSpline.CreateCurve(iPts, weights)
#Transaction end:
TransactionManager.Instance.TransactionTaskDone()
OUT = spline
Hi @MartinSpence thank you for your answer!