algorithmic modeling for Rhino
Dear All,
I need to use the "Shatter curve" component inside a Custom VB script but I am facing some issues.
My first question is: is there any document where we can access directly the VB.Net code of default Grasshopper Components (like Shatter, Extend Curve, and so on)? So we could re-use them inside a custom script. I had a look in the Grasshopper SDK but it doesn't appear to be here.
There may be a good reason not to provide the code but please advise if there is no point looking for it.
Then, the code giving me troubles is this one. It looks like the method "Closest Point" is not giving me the closest point! Can anyone advise what's wrong?
ByVal Crv1 as curve
ByVal pt1 as point3d
ByVal pt2 as point3d
Dim t(1) as double
Crv1.Domain = New interval(0, 1) 'Reparametrize for further use
Crv1.ClosestPoint(pt1,t(0))
Crv1.ClosestPoint(pt2,t(1))
Crv1.Split(t)
Thanks for your help
Tags:
Grasshopper is not open source :/
I have not tested but try replacing Dim t(1) as double by
Dim t as double() = new double(1){}
That's a good reason :-)
Just tried what you suggested but it gives me the same result.
Actually, all my t parameters values t(0) and t(1) are equals despite points are differents.
This works for me.
Private Sub RunScript(ByVal Crv1 As Curve, ByVal Pt1 As Point3d, ByVal Pt2 As Point3d, ByRef A As Object)
Dim t As Double() = New Double(1){}
Crv1.Domain = New interval(0, 1)
Crv1.ClosestPoint(pt1, t(0))
Crv1.ClosestPoint(pt2, t(1))
A = Crv1.Split(t)
End Sub
It looks like it's a bit more complicated for me, it works sometimes only.
Please have a look at the code / out screenshots
I have an array with 4 values of t (shattering points and 2 test points). I extract the first two with a "Redim Preserve t(1)" command.
In the first case, the redim is correct, Line 7 = Line 2 and Line 8 = Line 3. It just kept the first two values like it is supposed to be.
But, for the second curve starting Line 9, some t values are messed up after the Redim. Line 16 = Line 17 despite Line 11 was different from Line 12. That's what is creating a problem later in the Split.
Weird.
Imposible to see what are you doing with this information xD.
Why are you redim the array? If you need change the size of the array, maybe is best for you to use a list, instead of an array.
If you only want to extract a value, with array(index) is sufficient.
Ok no worries. I found a workaround by using separate variables instead of an array, it works fine. I still don't know where was this issue coming from, maybe from the instantiation of the array as you mentionned earlier.
Thanks for your help anyway,
Cheers
The concept: instantiate.
Dim MyDog as Dog = new Dog()
You're saying, the variable "MyDog" refers to the class "Dog" and to this variable you instantiate a new object "Dog". That is, with "= new Dog()" you are giving a value to the variable, assigning a space in the memory. Also you can instantiate that variable with other variable of class Dog or with an own class method (if available).
Dim MyDog as Dog
Without this value, the variable "MyDog" only refers to a type of object but its value is null or nothing, then any property or function of class in this variable will fail, because its value does not exist.
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
© 2024 Created by Scott Davidson. Powered by