algorithmic modeling for Rhino
It's based on this function. Please let me know if I should assist further.
Thanks,
- Giulio
_______________
giulio@mcneel.com
Hallo i'm trying to write this function in VB. But something is wrong...
I wrote this as follow:
Private Sub RunScript(ByVal CPoints As List(Of Point3d), ByVal degree As Integer, ByRef A As Object)
Dim cv As Curve
Dim d As IEnumerable(Of point3d) = CPoints
cv.createInterpolatedCurve(d, degree)
A = cv
could anyone adjust this?
thanks
Private Sub RunScript(ByVal points As List(Of Point3d), ByVal degree As Integer, ByRef A As Object)
A = Curve.CreateInterpolatedcurve(points, degree)End Sub
Allow me to explain your code line by line and why it doesn't work:
Dim cv As Curve: This line declares a new variable of type Curve, but it doesn't actually create a curve. cv will be a null reference (Nothing in VB). You cannot call methods on this instance because it doesn't exist.
Dim d As IEnumerable(Of point3d) = CPoints: You don't need to do this. IEnumerable(Of T) is an interface which indicates that whoever implements it represents a collection of objects that can be iterated over. List(Of T) already implements this interface, as do almost all collection based types in the .NET framework. I.e. when a function wants an IEnumerable(Of Point3d), you can feed it List(Of Point3d) or a Point3d array and it will all work.
cv.createInterpolatedCurve(d, degree): CreateInterpolatedCurve() is a Shared method. "Shared" in this case means it is not tied to a specific instance of the Curve type, but shared amongst all of them. It's a bit of a misnomer in my opinion, I think it would have been better if they had used the word "Loose" or "Floating" or something to describe Shared methods. But, long story short, since Shared methods do not belong to particular instances of a type, they can (and should) be called on the typename. C# enforces this behaviour, VB is more slack about it. In this case, CreateInterpolatedCurve() ought to be called on the Curve type name, not on any variable that represents an instance of the Curve class.
Also, the CreateInterpolatedCurve() method returns the resulting curve, so you must assign it to something otherwise it will fall into a black hole. In my example it is assigned directly to A, but you could also assign it to cv first:
Dim cv As Curve = Curve.CreateInterpolatedCurve(points, degree)
Hope this helps.
--
David Rutten
david@mcneel.com
Poprad, Slovakia
Thank you for your detailed explaie, David.
You have been very Helpful!
Welcome to
Grasshopper
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
© 2024 Created by Scott Davidson. Powered by