I'm trying to work with a series of curves in a VB.net component. However, I can't seem to use the Oncurve type. It returns an error saying it is protected.
Any ideas how to work with curves in VB.net or what alternate type I should be using?
You can't just use OnNurbsCurve methods on an OnCurve because there's no guarantee that the OnCurve you have is an OnNurbsCurve. All OnNurbsCurves are OnCurves, but all OnCurves are not OnNurbsCurves.
The best way to get an OnNurbsCurve is to use the GetNurbForm method that should be supported by OnCurve and all OnCurve derived classes.
Hmm. This should be pretty straightforward for the more advanced crowd.
1. GH produces a set of polylines (really a set of joined straight line segments)
2. I pass this as a flat list into a VB component.
3. I want to run through that list and for example compute the centriod of the closed polyline or find the max/min xyz value along its length but in order to do that, I need to deal with a specific polyline at a time.
4. Thus
for i as int32 = 0 to IncomingListOfPolylines.count-1
dim currentcurve as new xxxx
Currentcurve = IncomingListOfPolylines.item(i)
'do something with currentcurve
next i
I've tried xxxx as
OnPolyline
OnNurbsCurve
OnArcCurve
but no luck. The only way I've been successful in bringing the polyline in is as an exploded polyline and then I deal with a set of OnLine which is ok but not great.
None of those have worked because declaring the target variable as the type that you need will not automatically convert the curve. You need to manually do this in order to have something that is usable. As I mentioned before, the GetNurbsForm method will work to get you a nurbs curve, so things would look like this.
Dim currentCurve as New OnNurbsCurve()
IncomingListOfPolylines(i).GetNurbsForm(currentCurve)
You also have other options here. If you really want a OnPolyLine representation of the curve, you can use the IsPolyLine method that's supported by OnCurve and pass in an ArrayOn3dPoint. From there you can work either directly from the points or create an OnPolyLineCurve and go from there.