Grasshopper

algorithmic modeling for Rhino

I'm reviewing an older tutorial that Woo Jae Sung put together. It was composed before RhinoCommon came into use, so as I study it I am also trying to translate it into RhinoCommon as I am on Rhino5 now..

It's basically using a 3d framework to define points on the framework and then interpolate curves through them.

Right now Im assuming that I merely translated something incorrectly early in the script that lead to most of the definition issues later on...?? It also seems I am not using the append function correctly... :(

If anybody well versed could take a look it would be awesome...  :)

The code I've used is below and the erros I get are attached here:

  Private Sub RunScript(ByVal ptSetA As List(Of Point3d), ByVal ptSetB As List(Of Point3d), ByVal divU As Integer, ByVal divV As Integer, ByRef A As Object, ByRef B As Object)

    Dim n As Integer = 0

    Dim ptListA As New List(Of list(Of Point3d))
    Dim ptListB As New List(Of list(Of Point3d))


    For i As Integer = 0 To divU

      Dim ptRowA As New List(Of Point3d)
      Dim ptRowB As New list(Of point3d)

      For j As Integer = 0 To divV

        Dim ptA As New Point3d(ptSetA(n))
        Dim ptB As New point3d(ptSetB(n))

        ptRowA.Add(ptA)
        ptRowB.Add(ptB)

        n = n + 1



      Next

      ptListA.Add(ptRowA)
      ptListB.Add(ptRowB)

    Next

    Dim intcvListA As New List(Of NurbsCurve)


    For i As Integer = 0 To divU - 1 Step 2
      For j As Integer = 0 To divV - 1 Step 1

        Dim pt01A As New point3d((ptListA(i)(j) + ptListA(i)(j + 1)) / 2)
        Dim pt01A As New point3d((ptListA(i + 1)(j) + ptListB(i + 1)(j)) / 2)
        Dim pt01A As New point3d((ptListA(i + 2)(j) + ptListA(i + 2)(j + 1)) / 2)
        Dim pt01A As New point3d((ptListA(i + 1)(j) + ptListA(i + 1)(j + 1)) / 2)

        Dim dis01A As Double = pt01A.DistanceTo(pt04A)
        Dim dis02A As Double = pt03A.DistanceTo(pt04A)
        Dim vt01A As New Vector3d((pt04A - pt01A) / dis01A)
        Dim vt02A As New Vector3d((pt03A - pt04A) / dis02A)



        Dim pt01B As New point3d((ptListB(i)(j) + ptListB(i)(j + 1)) / 2)
        Dim pt01B As New point3d((ptListA(i + 1)(j) + ptListB(i + 1)(j)) / 2)
        Dim pt01B As New point3d((ptListB(i + 2)(j) + ptListB(i + 2)(j + 1)) / 2)
        Dim pt01B As New point3d((ptListB(i + 1)(j) + ptListB(i + 1)(j + 1)) / 2)

        Dim dis01B As Double = pt01B.DistanceTo(pt04B)
        Dim dis02B As Double = pt03B.DistanceTo(pt04B)
        Dim vt01B As New Vector3d((pt04B - pt01B) / dis01B)
        Dim vt02B As New Vector3d((pt03B - pt04B) / dis02B)




        Dim ptArrA As New List(Of Point3d)
        ptArrA.Append(pt01A)
        ptArrA.Append(pt02A)
        ptArrA.Append(pt03A)
        Dim intcvA As New NurbsCurve()
        intcvA = CreateInterpolatedCurve(ptArrA, 3)
        intcvListA.Add(intcvA)

        Dim ptArrB As New List(Of Point3d)
        ptArrB.Append(pt01B)
        ptArrB.Append(pt02B)
        ptArrB.Append(pt03B)
        Dim intcvB As New NurbsCurve()
        intcvB = CreateInterpolatedCurve(ptArrB, 3)
        intcvListB.Add(intcvB)

      Next

    Next

    A = intcvListA

Views: 425

Attachments:

Replies to This Discussion

OK, and this is his diagram of what is happening.

In arrays, add new elements with .append,

in lists, add new elementos with .add.

I have corrected those errors, but the script does not work as it should. There are many strange things. I do not understand what makes this script with the explanation that you have given, if you give more details maybe I can help (better a picture). Since it comes from an old logic, it may be absurd translate literally and is better to rethink from scratch.

Hi Daniel,

really appreciate you taking a moment to look at this.

This may sound like a dumb question, but I'm still not even intirely clear on the difference in the way that lists and array are called or defined... in looking at the tutorial LIFT architects put together, they talk about it but lists and arrays get lumped together as a general way  of calling forth groups of data... and I didn't see where they are specifically different... at some points it even looks like they refer to them as if they are almost synonomous... /:-(

With what youre saying about the logic of this script, that would make sense if the logic need be entirely rethought... it's from quite a while back.  Can I just give you the pdf. here without it being to tedious for you to look and offer some thoughts? 

http://wooj.files.wordpress.com/2009/05/grasshopper-tutorial-woojsu...

Let me know if I can make it more clear..  Thankyou again.

Arrays and lists are types of collections, although sometimes used for the same, they have different properties and methods. I enclose a script so you see the difference between three types of collections (list, array and datatree). I hope this helps you understand the difference. And also:

https://msdn.microsoft.com/es-es/library/system.array(v=vs.110).aspx

https://msdn.microsoft.com/es-es/library/6sh2ey19(v=vs.110).aspx

Attachments:

Thanks so much Daniel.  That was awesome :)

Im not sure if you had a moment to look at the entire script logic, but if you did did it seem like it was a script that needs to be rethought if it were to be rewritten now?

RSS

About

Translate

Search

Videos

  • Add Videos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service