DynamoDS / Dynamo

Open Source Graphical Programming for Design
https://dynamobim.org
Other
1.72k stars 632 forks source link

NurbsCurve.ByControlPointsWeightsKnots fails in Python #13760

Open JacobSmall opened 1 year ago

JacobSmall commented 1 year ago

Issue Description

NurbsCurve.ByControlPointsWeightsKnots fails when called via Python

Dynamo version

Pretty much all of them: 1.34, 2.0, 2.3, 2.10, 2.12, and 2.17 (or every version I had open at the moment)

What did you do?

Attempted to call NurbsCurve.ByControlPointsWeightsKnots in a Python script with the relevant inputs using this sample code:

import sys, clr
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *
xSet = [0,2.5,5,7.5,10]
ySet =[0,2,0,-2,0]
zSet = [0,0,0,0,0]
pnts = [ Point.ByCoordinates(x,y,z) for x,y,z in zip(xSet,ySet,zSet) ]
weights = [1,1,1,1,1]
knots = [0,0,0,0,5,10,10,10,10]
degree = 3
OUT = NurbsCurve.ByControlPointsWeightsKnots(pnts,weights,knots,degree)

What did you expect to see?

The Nurbscurve generated and returned to the Dynamo environment.

What did you see instead?

Warning: IronPythonEvaluator.EvaluateIronPythonScript operation failed. Traceback (most recent call last): File "", line 11, in TypeError: expected IEnumerable[Point], got list

github-actions[bot] commented 1 year ago

Thank you for submitting the issue to us. We are sorry to see you get stuck with your workflow. While waiting for our team member to respond, please feel free to browse our forum at https://forum.dynamobim.com/ for more Dynamo related information.

mjkkirschner commented 1 year ago

I think this will help:Assigning a Iron Python list to .NET arraystackoverflow.comA Python list is not a generic Ienum. On Feb 19, 2023, at 8:46 AM, github-actions[bot] @.***> wrote: Thank you for submitting the issue to us. We are sorry to see you get stuck with your workflow. While waiting for our team member to respond, please feel free to browse our forum at https://forum.dynamobim.com/ for more Dynamo related information.

—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you are subscribed to this thread.Message ID: @.***>

JacobSmall commented 1 year ago

Yeah - that might work - and i'll give it a shot later this week. But this is the only constructor or method in the Dynamo library (least the only one I have seen so far) that requires direct conversion... Is that intentional?

JacobSmall commented 1 year ago

I can confirm this works:

import sys, clr, System
from System import Array
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *
xSet = [0,2.5,5,7.5,10]
ySet =[0,2,0,-2,0]
zSet = [0,0,0,0,0]
pnts = [ Point.ByCoordinates(x,y,z) for x,y,z in zip(xSet,ySet,zSet) ]
weights = [1,1,1,1,1]
knots = [0,0,0,0,5,10,10,10,10]
degree = 3
pntsList = Array[Point](pnts)
wgtsList = Array[System.Double](weights)
knotsList = Array[System.Double](knots)
OUT = NurbsCurve.ByControlPointsWeightsKnots(pntsList,wgtsList,knotsList,degree)