Grasshopper

algorithmic modeling for Rhino

I was looking at the VB examples by Rajaa Issa, that does this:



Can I achieve this effect [image below] using similar logic? I mean using the looping to make the point go up and down? 



I'm a beginner and am obviously very bad at this! Please help :(



    Dim points As New List(Of On3dPoint)
    Dim dis_i As New Double  
    Dim i As New Integer
    Dim count As New Integer
    count = dis.Count()

    For i = 0 To count - 1
      'Get current distance in the array
      dis_i = dis(i)
     
      'Instantiate new point
      Dim new_pt As New On3dPoint
      Dim new_pt2 As New On3dPoint
     
      'Set point values
      new_pt.x = point.x + (dis_i)
      new_pt.y = point.y
      new_pt.z = point.z + (dis_i)
     
      'Set point values
      new_pt2.x = new_pt.x + (dis_i)
      new_pt2.y = new_pt.y
      new_pt2.z = new_pt.z - (2 * (dis_i))
     
     
      'Add point to list
      points.Add(new_pt)
    Next
     
    A = points

Views: 332

Replies to This Discussion

It looks an awful lot like a sine wave, are you sure you want to tackle this via index-math?

Where does point come from? What's inside dis? Are you looking to alternate the points (left, middle, right, middle, left, middle .....)?

Your code, with minor changes:

Dim points As New List(Of On3dPoint)

For i As Integer = 0 To dis.Count - 1
'Instantiate new point
Dim pt1 As New On3dPoint
Dim pt2 As New On3dPoint

'Set point values
pt1.x = point.x + dis(i)
pt1.y = point.y
pt1.z = point.z + dis(i)

'Set point values
pt2.x = pt1.x + dis(i)
pt2.y = pt1.y
pt2.z = pt1.z - 2 * dis(i)

'Add point to list
points.Add(pt1)
points.Add(pt2)
Next

A = points


--
David Rutten
david@mcneel.com
Poprad, Slovakia
Thanks David :)

Well I was just trying to understand how scripting works and this was just something that came to my mind...The example by Rajaa has many points forming a wave, but I wanted the points to be the nodes of a sine curve - the curve being achieved with interpolate curve later on.

I expected your modified code to do this, but it just gives a null output. I don't quite understand why

RSS

About

Translate

Search

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service