algorithmic modeling for Rhino
Hi, ive run into a problem. im writing the C# code to join three seperate curves such as below. Think of them, for the purpose of this example as three sides of a triangle.
RhinoList<Curve> cartman = new RhinoList<Curve>();
cartman.Add(x);
cartman.Add(y);
cartman.add(z);
now, in wanting to join these curves im using code similar to whats below.
Curve[] kenny = Curve.JoinCurves(cartman);
so far so good. But here is where the problem starts. If i pass the join curve out of the C# node i get 1 polyline curve, which is great. But within my node I have a Curve array with 3 elements in it.
What im trying to do is get the bounding box of the closed curve (ie something similar to below
BoundingBox test = kenny.GetBoundingBox(Plane.WorldXY);
but i cant call the "GetBoundingBox(Plane.WorldXY)" method on a Curve[]. i can only call it on a Curve type (ie not an array of type Curve)
How do i convert my array of three curves (that i thought were joined?) into an object that i can be the 2 dimensional bounding box of?.... I need to complete this operation within the current C# node, because it will be a piece of info for another method, but im stuck right here on this one.... Help!?
Tags:
Hi Mario, kenny is an array with only one item (the joined curve), so just get the first item. Since I don't know how to write C#, here's what I'd do in VB:
kenny(0).GetBoundingBox(Plane.WorldXY, bbox)
however simply running it through a VB>C# translator results in errors in the script which I don't know how to fix. Maybe you do...
ah.... yeah, that worked. i didnt realize the closed curve is in the first index of the Curve[] array.
thanks!
but now what i dont understand is why do i need to create and array to store the return of the Curve.JoinCurves() function.
Because JoinCurves returns an array of curves. It is entirely likely that not all the curves supplied can be joined, or maybe they are joined into multiple aggregates. However since .NET is a type-safe language, a function cannot change the return type based on any particular call. It must always return an array of curves, even if in some case it will only ever return a single result.
It's for situations where cartman for example holds three more curves (to stay close to your example), that can be joined into another triangle.
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