Grasshopper

algorithmic modeling for Rhino

Hi,

I have a Polyline (crazy one) that I Divided to points,
Now I want to write a VB script, But for my script I need to give each point a number 

in my script I called the list of numbers (whole numbers of point) index
and I called the last point as indexMax 
that what I wrote I am sure that I made some mistakes- so if one of you can help me I will be more then glad




  If abc(sin(3 * pi() * ptList / ptLast)) < 0.5 Then             harmony = 3 = z, 2 = x, 1 = y
    A = 0
    Else
    A = 1

    n = 0
    For n < ptLast
      If A(n) = A(n + 1) Then
        Zf(n) = Z(n) + 12 * A(n)
        n = n + 1
      End If

      (n + 4) < ptLast Then
      Zf(n) = Z(n) + 12 * A(n)
      Zf(n + 4) = Z(n + 4) + 12 * A(n + 4)
      Zf(n + 2) = Z(n + 2) + 6
      Zf(n + 1) = Z(n + 1) + 6 - 3 * (A(n + 4) - A(n))
      Zf(n + 3) = Z(n + 1) + 6 + 3 * (A(n + 4) - A(n))
      n = n + 5
  End If

  Else  M = ptLast - n
  For n<ptLast
  Zf(n) = (ptLast - n) / M * 12 * A(ptLast - M) + Z(n)
  n = n + 1
  End

Zf(ptLast) = Z(ptLast)

Views: 465

Replies to This Discussion

It would be easier to read if some of the variable names were more descriptive. For example, what is 'abc'?
Off the top of my head here are the mistakes I see:

'A' is sometimes being treated as a single value ('A=0') and sometimes a list ('A(n)=...')
'For' loop needs a Next to close it (probably the line after n=n+1)
'For' loop should be in the format 'For n=0 to (ptLast-1)'
'(n + 4) < ptLast Then' needs an 'If' in front of it
To use 'Else' you should not put End If until the end of the sequence , 'If ( ) Then... Else... End If'
'For' loop needs 'Next' again (probably the line after n=n+1)
'End' should be 'End If'
I wrote abc by mistake I meant Abs (absolute value)

I made some changes and attached here
Attachments:
Hi ome,

I'm very confused. Allow me to list the bits I don't understand in GH_DeadSea_Porject_Slubs02.cs:

1) void harmony (int Param)
Is this supposed to be a method declaration? What's it supposed to do?

2) if (abs(sin(3 * pi() * ptList / ptLast)) < 0.5)
abs and sin are written with upper case letter and they are part of Math: Math.Abs(), Math.Sin()
Where is pi() coming from? It's a constant, not a function: Math.PI

3) if (ptList == A(n + 1))
Where is ptList defined?
A is of type Object, you cannot use it as a function. You've assigned the constants zero or one to A at the top of the script, how is it ever supposed to be == to ptList?

4) Zf(n) = Z(n) + 12 * A(n);
Again, Zf and Z are not defined anywhere as far as I can tell.

5) M = ptLast - n;
Where does M come from?

6) The script doesn't seem to do anything. Any values you want to output from your script back into Grasshopper have to be assigned to the A parameter, but you're only assigning to A right at the top.

Perhaps it would be better if you explained in English what you are trying to accomplish with this script.

--
David Rutten
david@mcneel.com
Poprad, Slovakia
I'll try to explain it,

My Idea is to use one polyline from my cad plane and use it as a base to a NEW POLYLINE that will be a 3d line which contain some design parameters, This line will be my base line for a slab (box/story).

The New Polyline Parametrs are:

1. Both new and old polyline should have the same 4 segments in its beginning and its end.

2. The New Polyline changes periodically in each axis independently.

3. I each axis they are 2 main options:
A. (in each axis) The coordinate is either equal to the "old" coordinate.
OR B. Differs form the "old" coordinate in a certain gap (specific for each coordinate) and always to the same direction (specific for each coordinate).

4. When it changes from "A" type to the "B" type and back appear the change need to be gradual therefor it need to be escalate during 4 segments.



I want to be able if it is possible to have the control of:
1. changing the paired of each axis.
2. control the discreet gap of each axis and direction.
3. define the minimum size of a segment.

Thanks
Ok, so let me rephrase it to see if I understood this:

1) you have a polyline input curve.
2) you want to create a second polyline, based on the first polyline.
3) The second polyline is allowed to deviate from the first one using custom distances along all three world (x, y & z) axes.
4) The first four and last four segments need to be identical in both cases.

I'm not entirely sure where your point #4 applies to. Is it about the first and last 4 segments? or are we talking about blending between states on the interior of the polyline?

--
David Rutten
david@mcneel.com
Poprad, Slovakia
You are absolutely correct

and bout the Q
1. The first four and last four segments need to be identical in both cases.
2. after a change in an axis this axis (x/y/z) the ext 4 segments (at least) get the parameter as the first polyline + the change:
if the first polyline segments was :
pt80{8,9,0}, pt81{10,10,0}, pt82{12,11,0}, pt83{16,11,0}, pt84{19,12,0}...pt89{26,20,0}

then in the new polyline I want it to be (with a change in the x axis of 8 segments)
pt80B{8+8,9,0}, pt81B{10+8,10,0}, pt82B{12+8,11,0}, pt83B{16+8,11,0}, pt84B{19/19+8,12,0}...pt89B{26,20,0}

Thank you for all the help
and you made everything to sound so easy
Ahhh ok. So once you create a deviation, you want to maintain that deviation for another 4 segments (i.e. 5 corners). I get it now.

How do you pick the initial deviation? Is it a random thing? Do all three axes 'toggle' their deviation at the same time, or are they not linked?

I'll write up a small script with my understanding so far. Then we can go from there.

--
David Rutten
david@mcneel.com
Poprad, Slovakia
I wanted it to random,
there I thought that each axsis change at a different time and it will be random

I couldn't figure how to make it more random

and again thank you so much
Attached: polyline randomization in C#. It's probably not exactly what you had in mind, but it might point you in a useful direction.

--
David Rutten
david@mcneel.com
Poprad, Slovakia
Attachments:
David
This is extremely helpfully,
Now I understand everything better
I am working on that and hopefully will go over that.

RSS

About

Translate

Search

Photos

  • Add Photos
  • View All

Videos

  • Add Videos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service