Grasshopper

algorithmic modeling for Rhino

Is this possible? I can't figure out how. Would be glad if somebody could help me.

In my special case i would need the corners of a polyline. has anybody done that?

Views: 1815

Replies to This Discussion

You'll have to convert the OnCurve to an OnNurbsCurve, and then get the control vertices from that. Your special case of a polyline doesn't really matter, so this should work for getting the CVs from any curve. The example below assumes two inputs, crv and i, which are typed as an OnCurve and Integer, respectively

Dim nCrv As New OnNurbsCurve
crv.NurbsCurve(nCrv)

If i < nCrv.CVCount Then
Dim cvPt As New On3dPoint()
nCrv.GetCV(i, cvPt)
A = cvPt
Else
A = "Beyond Last Index"
End If
Damien's code would get you a specific CV by index.. you could use the same code and put it in a FOR loop to get all CVs..

If you are dealing with a polyline, you dont even need to script.. just use a 'decompose' (I'm not sure about the name.. it could be called Explode or shatter) component which will give you lines, and then use Curve.EndPoints to get all the start pts or end pts of the lines..
Thank you guys!

I'm glad to have Damiens answer, even if i don't need it for that special case of a polyline. But i can remember a situation about a month ago where i have been looking for a curves control points and couldn't find it in the SDK. Can't remember the workaround i did then, but in the future i will be able to get them through scripting.

Even quicker is to use the Discontinuities component, it will give you polyline vertices directly.

here's a specific VB script that extracts all points of a polyLine:

Private Sub RunScript(ByVal x As OnCurve, ByRef A As Object)
Dim ptList As New List( Of On3dPoint)
Dim pLine As New OnPolyline

If x.IsPolyline(pLine) Then
For i As Int32 = 0 To pLine.Count() - 1
ptList.Add(pLine(i))
Next
End If

A = ptList

End Sub
hello

does anyone know how to create polylines from on3points in a vb node?
without having to write a function?

thank you
Dim mycrv as new OnPolylineCurve(CVarray)

Thats it!

RSS

About

Translate

Search

Photos

  • Add Photos
  • View All

Videos

  • Add Videos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service