Grasshopper

algorithmic modeling for Rhino

Hi

 

I'm trying to write a simple script to offset a curve muliptle times (using a 'for loop') but I don't know the vb dotNet syntax. I'm sure lines 84, 88 & 89 are wrong. Any ideas.

 

Thanks. P

Views: 3470

Attachments:

Replies to This Discussion

Hi Paul,

where did you get On3dCurve from? There's no such class in the Rhino SDK. I think you want to use OnCurve.

Dim newCrv As New On3dCurve

Once you remove the "3d" in that line it still won't work. OnCurve is an abstract (MustInherit in VB) class and cannot be constructed. But you don't have to create a new OnCurve, as it is the job of the RhinoOffsetCurve function to create it for you.

Also, RhinoOffsetCurve (there's no dot between "Rhino" and "OffsetCurve" btw) returns an array of curves, as a single offset may generate any number of partial results.

All in all, this SDK function is pretty darn complicated. Is there any humane way in which I can convince you to switch to Grasshopper 0.7.X and the RhinoCommon SDK? This would be much easier.

--
David Rutten
david@mcneel.com
Poprad, Slovakia
Hi David

Thanks for your reply. Not quite sure what you mean by your response...

I've downloaded Grasshopper 0.7.X. Where can I download RhinoCommon SDK? I'm not sure how these will help me. What is the code I need to use?

Thanks. P
Hi Paul,

since Grasshopper 0.7, the default scripting components use the RhinoCommon SDK. There are still legacy scripting components that use the old Rhino SDK (the legacy components have pixelated icons).

In RhinoCommon, classes are no longer prefixed with the "On" or "MRhino" code.

If you post your file, I'll write the code directly inside of it.

--
David Rutten
david@mcneel.com
Poprad, Slovakia
Hi David

Thanks for that. File attached. I have 2 script nodes - common and legacy. Can you modify both so I can compare the differences.

Where is the best place to find documentation on the syntax for RhinoCommon SDK.

Thanks. P
Attachments:
My attempts using the new (RhinoCommon) components:

Private Sub RunScript(ByVal rows As Integer, ByVal width As Double, ByVal crv As Curve, ByRef A As Object)
  Dim plane As Plane
  If (Not crv.TryGetPlane(plane, 1e5)) Then Return

  Dim rc As New list(Of Curve)
  For i As Integer = 1 To rows
    Dim offset_curves As Curve() = crv.Offset(plane.ZAxis, plane.Origin, i * width, 0.01, 0.1, CurveOffsetCornerStyle.Round)
    If (offset_curves Is Nothing) Then Continue For

    Dim join_result As Curve() = Curve.JoinCurves(offset_curves)
    If (join_result Is Nothing) Then Continue For

    rc.AddRange(join_result)
  Next
  A = rc
End Sub

--
David Rutten
david@mcneel.com
Poprad, Slovakia
Hi David

Thanks for that. It works. But I've just found the series button and that seems to be a much easier method...
Attachments:

RSS

About

Translate

Search

Videos

  • Add Videos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service