Archinect

Knowlton School of Architecture (2005-2009) (Evan)

  • anchor

    Seeking Grasshopper/VBscript Master....

    Evan Chakroff
    Feb 20, '09 1:04 AM EST

    so, following out midreview (which went very well for me), i've been looking into ways of introducing apertures into the surfaces of my project. our critics suggested "gills" as a method, so i've been hacking away at grasshopper and rhinoscript in an attempt to make it work...

    so far, i've got a decent rhinoscript that does what i want it to:





    it takes two curves with an equal number of control points, and draws a new curve with most of the points from curve1, substituting every Nth point from curve2.

    which is great, and with a little elbow grease i can get something like this:



    so, that's all well and good, but i wish i could control it parametrically, and i'm intrigued by Grasshopper's new support of VB script... which, unfortunately, i know nothing about.

    so, i've posted to the google grasshopper group in hopes of getting this figured out, but i wonder if anyone here has a little more experience in this....

    my main issue is translating my working rhinoscript into a working VB component in GH....

    here's the rhinoscript that generated the images above... if anyone has any ideas how to get this working in VB please let me know, or join the discussion on the GH google group....

    thanks.

    code:

    Option Explicit

    Call NewCurveFrom2
    Sub NewCurveFrom2()
    Dim strCrv1 : strCrv1 = Rhino.GetObject("Pick Curve 1", 4, True)
    If IsNull(strCrv1) Then Exit Sub
    If Rhino.IsCurveClosed(strCrv1) Then Exit Sub

    Dim strCrv2 : strCrv2 = Rhino.GetObject("Pick Curve 2", 4, True)
    If IsNull(strCrv2) Then Exit Sub
    If Rhino.IsCurveClosed(strCrv2) Then Exit Sub

    Dim strCrv3 : strCrv3 = DrawCurve3(strCrv1, strCrv2)

    End Sub

    Function DrawCurve3(ByVal strCrv1, ByVal strCrv2)

    Dim arrCrv1pts : arrCrv1pts = Rhino.CurvePoints(strCrv1)
    Dim arrCrv2pts : arrCrv2pts = Rhino.CurvePoints(strCrv2)

    Dim arrCrv3pts : arrCrv3pts = arrCrv1pts

    Dim N : N=5

    Dim i
    For i = 1 To UBound(arrCrv2pts) - 1

    Dim iOverN : iOverN = (i/n)
    Dim intiOverN : intiOverN = Int(iOverN)

    If intiOverN = iOverN Then
    arrCrv3pts(i) = arrCrv2pts(i)
    Else
    arrCrv3pts(i) = arrCrv1pts(i)
    End If
    Next

    Dim strCrv3
    strCrv3 = Rhino.AddCurve (arrCrv3pts, 2)

    End Function



     
    • 3 Comments

    • difficultfix

      Actually grasshopper does not support VB script, It uses VB net script, which is really not scripting but a way of using code to work Grasshopper.

      Feb 21, 09 11:44 pm  · 
       · 

      yeah i have no idea about these various languages. i just want to know enough to rip off someone's code and make it work for my project...

      Feb 22, 09 2:36 am  · 
       · 
      larrya91

      Interesting article and nice blog you have too! Larry blog

      Jan 11, 10 4:02 am  · 
       · 

      Block this user


      Are you sure you want to block this user and hide all related comments throughout the site?

      Archinect


      This is your first comment on Archinect. Your comment will be visible once approved.

    • Back to Entry List...
  • ×Search in:
 

About this Blog

Thoughts on the M.Arch I program at the Ohio State University, 2005-2009, plus additional work with OSU as a critic and lecturer.

Affiliated with:

Authored by:

Other blogs affiliated with The Ohio State University:

Recent Entries