@oliver_1992 wrote:
Hello.
I´m very unsure how to deal with curves of the type Polyline and PolylineCurves.
I did this simple grafting component to reproduce the error I get in another script I’m working on.
For my understanding, if I pass a Referenced Polyline Curve to my Grasshopper component, it is of a Polyline Type. So I convert it with ToPolylineCurve () to a PolylineCurve type, so I could use the methods of the Curve Class. Now I graft it and output a tree of PolylineCurves.
I get the error -> 1. Invalid cast: Curve » PolylineCurve
Does anybody know what I’m doing wrong?protected override void RegisterInputParams(GH_Component.GH_InputParamManager pManager) { pManager.AddCurveParameter("iPolyline", "iPolyline", "iPolyline", GH_ParamAccess.list); } protected override void RegisterOutputParams(GH_Component.GH_OutputParamManager pManager) { pManager.AddCurveParameter("oPolylineCurves", "oPolylineCurves", "oPolylineCurves", GH_ParamAccess.tree); } protected override void SolveInstance(IGH_DataAccess DA) { List<Polyline> iPolylines = new List<Polyline>(); DA.GetDataList("iPolylines", iPolylines); List<PolylineCurve> temp = new List<PolylineCurve>(); for (int i = 0; i < iPolylines.Count; i++) { temp.Add(iPolylines[i].ToPolylineCurve()); } DataTree<PolylineCurve> oPolylineCurves = new DataTree<PolylineCurve>(); for(int i = 0; i < temp.Count; i++) { oPolylineCurves.AddRange(new List<PolylineCurve>() { temp[i] }, new GH_Path(i)); } DA.SetDataTree(0, oPolylineCurves); }
Thanks for reading my post.
Best wishes,
Oliver
Posts: 2
Participants: 2