Grasshopper

algorithmic modeling for Rhino

Hi, I am having trouble offsetting a curve with a VB component. it is probably quite simple but I have not been using GH for a while now and would very much appreciate some pointers to what I have done wrong.

 

extract from RhinoSDK

Public Function RhinoOffsetCurve(ByRef curve_in As IOnCurve, distance As double, ByRef direction_point As IOn3dPoint, ByRef normal As IOn3dVector, corner_style As Integer, tolerance As double, curves_out As [System::Runtime::InteropServices::Out]arraya>OnCurve^>^%) As Integer

 

 

 Private Sub RunScript(ByVal xCrv As OnCurve, ByVal yPt As On3dPoint, ByRef A As Object)

 

    Dim nPt1 As New On3dPoint(0, 0, 0)
    Dim nPt2 As New On3dPoint(0, 0, 1)
    Dim Normal As New On3dVector(nPt1 + nPt2)


    Dim Dist As Double = 3.0

 

    Dim nCrv As New OnNurbsCurve
    nCrv = RhUtil.RhinoOffsetCurve(xCrv, Dist, yPt, Normal, 0, 0.1)

   

    a = nCrv

 


  End Sub

 

 

Views: 447

Replies to This Discussion

hi eric

nCrv has to be an array and inside the function (it is byRef so will be returned there)
nCrv has to be an array because if your curve has kinks after the offset you will get more than one curve
Here is a working version of the script.

Dim Normal As New On3dVector(nPt1 + nPt2)
This addition is not acceptable because it is not belong to any Constructor of On3dVector class. Also, you need to be really careful figuring what return type of the method should be. In this case, RhUtil.RhinoOffsetCurve method returns Integer not OnNurbsCurve class type.

Private Sub RunScript(ByVal xCrv As OnCurve, ByVal yPt As On3dPoint, ByVal Dist As Double, ByRef A As Object)

Dim Normal As New On3dVector(0, 0, 1)

Dim nCrv() As OnCurve = Nothing

RhUtil.RhinoOffsetCurve(xCrv, Dist, yPt, Normal, 0, 0.1, nCrv)

A = nCrv

End Sub
Attachments:

RSS

About

Translate

Search

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service