Grasshopper

algorithmic modeling for Rhino

Hi,

I'm a total newbie to vbscript, but can operate reasonably well in Grasshopper.  I am hoping that someone might be kind enough to help me with what I think is a fairly simple task, yet has been causing me much stress to figure out!

Basically, I created a polyline in GH with a variable angle.  I would like to then like to perform two actions:

1. at each start point of the line, mirror a copy from its start point
2. at each end point of the line, mirror a copy from its midpoint

original polyline:                                               actions 1 (on left) and 2 (on bottom) performed:

 



I'd then need to loop this, so that they could be recursively copied off of each instance.  The generation would start to look like this, based on N iterations:



Unfortunately this needs to be done in vbscript rather than rhinoscript because I need to be able to see the movements of the system as the internal polyline angle changes.


I've attached the rhino file (only contains a point) and one of the many GH definitions I've tried.


Any and all help would be GREATLY appreciated--I've been stuck on this for over a week!

THANKS!!!


Views: 2386

Attachments:

Replies to This Discussion

Are mirror angles always vertical and horizontal, or do they depend on the angles inside the polyline?

--
David Rutten
david@mcneel.com
Poprad, Slovakia
Well, assuming the mirror angles are vertical and horizontal, here's a first stab.

EDIT: I think I'm making too many copies, the pattern slows down too quickly. Hang tight.

--
David Rutten
david@mcneel.com
Poprad, Slovakia
Attachments:
Man, I couldn't solve that properly, had to put in a nasty hack to make sure there were no duplicates in the pattern.

--
David Rutten
david@mcneel.com
Poprad, Slovakia
Attachments:
omg! this is AWESOME! THANK YOU, David! I've been beating my head against the wall on this for over a week now, and I never would have gotten that (especially the Sorted Dictionary stuff). Is that the part to eliminate duplicates?

The mirror angles for now just needed to be vertical and horizontal, as you suspected. My next task is to figure out how to give the pattern a curvature in the z direction, hopefully making some kind of spherical surface. Hopefully I can work that out without too much headache...

thanks again!
Yeah, the SortedDictionary is used to see if a certain polyline has already been added to the pattern. I convert the coordinates (x, y, z) of the second point on the polyline to a String, which can then be matched against a dictionary (collection) of strings. Rather than using a List(Of String) say, SortedDictionary allows for very quick Insertion and Search.

It would have been nice if there's a way to make this pattern that doesn't result in duplicates.

--
David Rutten
david@mcneel.com
Poprad, Slovakia
Okay, I think I've almost got it successfully making a rotational deformation, in order to make that cylindrical shape.

I've found that if I plug in a constant number (radians) into the script, it works fine:

Dim crv2 As OnPolyline = Action01(crv)

Dim pt0 As On3dPoint = crv2.Item(1) 'MidPoint
Dim pt1 As On3dPoint = crv.Last() 'EndPoint

Dim xf As New OnXform()
crv2.Translate(pt1 - pt0)
crv2.Rotate(0.087, New On3dVector(-1, 0, 0), pt0)

Return crv2
End Function


But, if I try to attach a slider to control that angle of rotation, and then define in the script that number by a variable, the script doesn't seem to pick up that number at all. Instead, it seems to ignore the rotation transformation entirely:

Dim crv2 As OnPolyline = Action01(crv)

Dim pt0 As On3dPoint = crv2.Item(1) 'MidPoint
Dim pt1 As On3dPoint = crv.Last() 'EndPoint
Dim j As Double

Dim xf As New OnXform()
crv2.Translate(pt1 - pt0)
crv2.Rotate(j, New On3dVector(-1, 0, 0), pt0)

Return crv2
End Function


Any thoughts on how I can get it to read that input?

Also, is there any way to limit the number of iterations in the X direction so that the overall surface won't have a diamond shape, but rather a rectangular (or otherwise) shape?

Thank you!!!
Attachments:
Hi Lian,

you cannot just declare a variable called j in a function and expect it to have the same value as a j in some other functions. Variables inside different functions do not communicate with each other.

Writing:

Dim j As Double

will declare a local double, which has a default value of zero. Unless you assign something to this variable, it will always be zero.

You need to share the value of j in RunScript with the Action02 function. The easiest way is to adjust the Action02 signature:

Private Function Action02(ByVal crv As OnPolyline, ByVal j As Double) As OnPolyline


Then, inside RunScript, you must supply j when calling Action02:

Dim crv2 As OnPolyline = Action02(crv, j)


--
David Rutten
david@mcneel.com
Poprad, Slovakia
Like so.

--
David Rutten
david@mcneel.com
Poprad, Slovakia
Attachments:
Thanks, David!!
Okay,

I've been wrestling with how to control the shape of the overall pattern into something other than a diamond. I thought that the script is outputting a diamond because it was lacking one extra transformation (i.e. endpoint-to-midpoint, instead of midpoint-to-endpoint, or iteration #4 in this diagram):


However, when I fixed the VB component to add this, the pattern just continued in its diamond pattern, only with one extra iteration along its bottom edges:

Before:


After:


Any thoughts out there?? Ultimately the pattern needs to be more rectangular in shape, and controllable by the number of iterations in the x direction. I've started to try to control cutting off the width in grasshopper (as seen in the definition), but so far I can only get it to cut off by the distance from a certain point, rather than the numbers of iterations. That becomes a mess when the internal angle changes, and the whole size of the system morphs... maybe if I come about the pattern in an entirely different way, it will be easier to control?

Any help is GREATLY appreciated! :-/
Attachments:
Haven't looked closely enough at the code to answer your real question, but in the meantime if you want a rectangular boundary why not cull based on your Decompose Point, X and Z values (Domain > Includes to make the Boolean Patterns). Cull by distance from a point will always create a circular boundary.
Trevor! I didn't know you were lurking here...

I got the script to fill in the bottom of the diamond (had to add *two* more iterations, rather than just one):


But the top of the diamond still eludes me.

Thanks for your tip, but a distance-based solution fails because the system is kinetic and its dimensions change (see attached animation). I need to find a way to count the number of polylines in the x-direction, and then limit them. It probably starts with the public function Count(), but I'm not sure how to specify only in the x-direction.

Maybe I should start a new thread for this.
Attachments:

RSS

About

Translate

Search

Videos

  • Add Videos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service