algorithmic modeling for Rhino
Good evening everyone,
I am writing a component using visual studio (c#), which gets as input a surface (EdgeSrf). Within the component, I loop through the edges and need to get the geometrical definitions, such as coordinates of the points.
I can't fix a problem and hope someone can help me, for converting the edge-definition
- the surface is a GH_Brep
- the contemplated edge type is Rhino.Geometry.BrepEdge (Nurbs Curve)
- needed conversion to GH_Curve
the conversion fails: "rtrn = false", but I don't know why
the code is as follows:
//declaration
GH_Brep area_GH = (GH_Brep)area
// object area is from type Grasshopper.Kernel.Types.GH_Brep
GH_Curve edge_GH = new GH_Curve();
bool rtrn = Grasshopper.Kernel.GH_Convert.
ToGHCurve(area_GH.Value.Edges[i], GH_Conversion.Both, ref edge_GH)
I hope someone has a suggestion.
Thank you, Konrad
Tags:
Replies are closed for this discussion.
Without testing, how about this:
Brep area = null;
if (!DA.GetData(?, ref area)) return;
if (area == null) return;
List<Curve> edges = new List<Curve>();
foreach (BrepEdge edge in area.Edges)
edges.Add(edge.DuplicateCurve());
DA.SetDataList(?, edges);
You don't have to use GH_Brep and GH_Curve if you don't want to, Breps and Curves will automatically be converted. Of course you can use GH_Brep, in which case you'll have to access it's Value property.
You can also construct a GH_Curve directly by providing it with a Rhino.Geomety.Curve.
Hi David,
a big thank-you to you. The last hint helped a lot, I didn't know about that and tried to use
GH_Curve edge_GH = new GH_Curve();
edge_GH = (GH_Curve)area_GH.Value.Edges[i];
instead of
GH_Curve edge_GH = new GH_Curve(area_GH.Value.Edges[i]);
Thank you.
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