Grasshopper

algorithmic modeling for Rhino

I have this script in RhinoScript. Can you please show me how I can do the same using VB.Net (and Python if possible) in GH? If there are existing side-by-side comparison, please direct me to those, it'd be great.

 

I am trying in Rhino 5 and would like to understand where to get the documentation and get the feel for the differences.

 

Also, do you write such scripts directly in the component? Or elsewhere? How can one debug them?

 

Thank you for your help.

 

Option Explicit

Call Main()

Sub Main()
   
    Dim arrObjects, arrMP, i
    Dim offsetSize
   
    offsetSize = 1

    arrObjects = Rhino.GetObjects("Select curves to offset")

    If IsArray(arrObjects) Then
   
        For i = 0 To UBound(arrObjects)
       
            arrMP = Rhino.CurveAreaCentroid(arrObjects(i))
           
            If IsArray(arrMP) Then
               
                Dim arrNewobject, strGroup, grpName
       
                arrNewobject = Rhino.OffsetCurve(arrObjects(i), arrMP(0), offsetSize, ,2)
         
                Rhino.AddLayer("offset")
                Rhino.ObjectLayer arrObjects(i),"offset"
                Rhino.ObjectLayer arrNewobject,"offset"
               
                strGroup = Rhino.AddGroup
                Rhino.AddObjectsToGroup arrObjects(i), strGroup
                Rhino.AddObjectsToGroup arrNewobject, strGroup

            End If
   
        Next

    End If
   
End Sub

 

Views: 823

Replies to This Discussion

Hi Anna,

 

this script isn't really translatable to Grasshopper. It asks the user for curves (though I suppose you'd use a script component input for that instead), it generates layers and adds objects using groups. There's nothing like layers and groups in Grasshopper. You don't need to script Rhino.OffsetCurve as there is already a component for that.

 

I can show you how to program this using VB.NET, but it seems like an odd example.

 

--

David Rutten

david@mcneel.com

Poprad, Slovakia

Thanks, David

 

Yes, I was imagining inputting a fully sorted list (with sorting and branching done in Grasshopper). Layering is less important but grouping is the point of it. I thought it was possible to cause events in Rhino using VB.Net in GH. Am I mistaken about it? Can I bake my curves to Rhino and group them per branch as I bake?

 

I would appreciate seeing it in VB.Net outside of GH too. Trying to get my head around RhinoCommon. In my first steps, I am finding it difficult to get at the right functions/classes and their descriptions. So, side-by-side examples would be great.

 

---

And on another note - might it be a good idea to let GH groups bake objects as groups in Rhino?

Any further advice? I am reading here that one can add geometry directly to Rhino from GHPython at least?

 

http://www.food4rhino.com/project/ghpython

 

Taking in a branched list, grouping per branch and creating objects/groups int he document sounds simple but is confusing to a beginner in the light of all the available options.

 

Thanks.

RSS

About

Translate

Search

Videos

  • Add Videos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service