Grasshopper

algorithmic modeling for Rhino

Hi Everyone, 

I'm looking to recreate a two dimensional cracking technique from python script into grasshopper, whilst also transferring it to 3D. It's relatively simple, drawing a line between the centre of the (in 2D case - closed polyline) the extremities, and then sub dividing and repeating.

I've started this off in 3D by creating a box, finding the centriod and then creating lines between the centroid and exterior vertices. Ideally I then want to create these "triangles" into surfaces, find the centre point of all of those, and then repeat (even better would be to somehow have the repeat count on a slider of some sort)

I'm attaching a couple of screen shots to help explain what I'm trying to achieve, would be very grateful if anyone had any suggestions, also included the grasshopper file, though I apologise in advance for how messy it is!

Views: 5114

Attachments:

Replies to This Discussion

Hi Tom,

I'm not sure how to get the script to function in 3D, I have previously downloaded both the python plugin and anenome for grasshopper, but have had some trouble getting them to work. (Still a big grasshopper newbie!)

As mentioned the main point is to be able to sub divide the box so that I can create a similar pattern to the 2D one shown, in 3D, with variables ill be able to control :) H

Well ...

... although NOT using P (I like C#) give the attached a spin. Impossible to auto translate to Python (and rather not suitable at all for a novice ... thus use it only as a toy for fun).

Works in 2 modes: fast (orthogonal "pieces") and very slow (pieces that MAY are suitable for a "broken" box). For the very slow part blame Rhino (is NOT a solid modeler you know... thus any "solid" opp takes ages).

You can exploit the recursion if you set the last bool to true.

The scale option gives you some hints more with regard the pieces made.

Attachments:

Thank you Peter!!

This is pretty much 100% what I was looking for! I only started using grasshopper in November and have limited expirience with Python (I found a tutorial online for the 2D example I showed) The non orthogonal pieces have actually been running pretty quickly on my machine which is reassuring!

Just a couple more things I was wondering if you could point me in the right direction of / explain;

1. Is it possible to have the centre point, from which the breaking occurs to be slightly offset?

2. Is it possible to have more then one origin of the break?

3. Could you explain a little about the X, XY, and XYZ choices?

Thanks agin,

Holly

Holly,

In fact absolute anything is possible ... but I wonder if you are interested for a "black box" kind of thing: I mean an "improved" C# that does whatever you want could be a good thing for you? On the other hand ... well ... we can pretend that this could be some sort of add-on dedicated for broken pieces, (and nerves if loops = a big number) he he.

Anyway:

1. If you enable the history (the yellow things) you can watch the recursion working: get a donor box and "slice" it in 2 (either via an "orthogonal" plane [the fast boxes] or a random one [the slow breps]). Then get each one and repeat until the desired "depth" of "slices" is achieved (the loops, that is). Pure recursion in terms of programming (a function does something, yields results and then calls itself to further process each result).

Double click on the C# to see the code (but don't change anything). For the record this is the function that does the main job (spot the fact that if it's not terminated it calls itself [last line]):

2. The x, xy, xyz options restrict the random plane (actually in the boxes case there's another technique used (Intervals) but never mind). For instance (case random breps) the slicing plane is defined at the brep center and using a random direction:

Vector3d dir = new Vector3d(rand.NextDouble(-1,1), rand.NextDouble(-1,1), rand.NextDouble(-1,1));

If the 3rd value is 0 then the plane's YAxis is parallel to Plane.WorldXY.ZAxis. 

3. Now if the "slicing" thing was a random polyline at a random plane the pieces could be far more "elaborated" (and/or "naturally looking") ... but the thing with programming is to know(?) where/when to stop.

4. This approach could use any donor Brep (a blob for instance) or a Brep List. Notify if you want to add such an option.

5. Added some lines more for an option that allows to sample the pieces (due to the last loop) in an automated flat "layout" (it's a bit more complex than it appears on first sight).

6. The x,y restriction mode now affects the random slices as well. See what I mean:

and the same restriction using boxes:

Truth is that all that freaky stuff could be helpful for you if you had serious plans to learn C# (not something achievable without pain and tears aplenty).

best

Attachments:

Hi Peter,

 

I’m literally lost for words you’ve managed all of this!

 

Excellent news that almost anything is possible, now I just need to learn how to use it…

 

I’ve had a peek at the C# code in an effort to experiment to see what would happen if certain aspects were changed, but quite frankly it wasn’t very successful, I’m now beginning to realise how different all the scripting is, when all I’ve ever used is python.

Thanks for Clarifying the XYZ functions, I saw the effect on the orthogonal version but was struggling on the Oblique one.

I’m much clearer on how the overall thing works now (thanks again)

Ooh the idea of using a doner Brep is great! A brep list, even better! Is this a simple thing to add in?

 

The layout option saves me a great deal of time moving all the individual pieces (as I did this morning haha!) so again much appreciated.

 

I think learning C# might be a summer job! I’ve got this far so whats a bit more pain and tears!

 

H

Well ... I have more that 7K "similar" things (all the design job [AEC sector] in the practice is carried over solely via code). So this thingy posted is more or less a collection of "suitable" existed functions.

Bad news: All that would become obsolete rather soon: AI is near-by (start digging a big deep rabbit hole, seal the door, stay inside).  

I'll do the V4 soon (adding some more freaky "slicing" options and some other things).

BTW: learning C# (for pro usage) MAY require slightly more than one summer (maybe 66 maybe 666 ... who's counting? he he). 

Wow! I'm sure a collection will suffice just fine! haha

Thanks for making the changes for me, one last thing I just remembered: Is it possible to grade the "gap" created between the slices, based on the order in which the slices occur?

e.g. the gap between the first and second object created is larger than that of the division between the ninth and tenth. (I'm now looking at the spaces between the objects as well as the objects themselves, so can Boolean the shapes to create the inverse!)

haha well im 6 years into Architecture school so what another few more years! I've been wanting to learn code for a while, just never really had the time, so why not start now!

H

Not sure what gap means. Make a sketch by hand since computers are not (yet) AI driven (not to mention humans).

Given the opportunity: BEFORE walking the code walk CAREFULLY list all the applications that may contribute into a future AEC workflow (for instance in my case in descending order of importance: ProjectWise, BIM/AECSOSim (core: Microstation Connect edition), Generative Components, MasterSpec plus various Bentley Systems verticals, plus CATIA and Siemens/NX) and try to learn the most suitable language that could(?) "bind" them all. GH may (or may not) play a role in all that. Rhino is out of question.   

BTW: testing some freaky thingy that does cracks that could qualify as "natural looking" (and pigs do fly):

Hopefully this should explain what I mean about the "Gap!"

I'm lucky in the sense that at the moment my design is mainly driven by rhino ang grasshopper, which I tend to then 2D export and work up in AutoCAD!

The cracks look excellent and pretty much complete what I'm looking for!

Would be great if you could upload this version!

Nothing is attached (Pending: what is a gap? you tell me).

The thingy with the "radial" cracks is a totally different C# written for some WIP project (don't ask). There's an issue with that thing: imagine the collection of "radial" random polylines as shown above (main and child ones: kinda a fractal 3d>2d tree so to speak). In order to make regions out of these you'll need to intersect each one with any other and then do some other freaky things and finally get the required closed polylines (or planar Breps). This is 100 times faster than attacking the problem via the recursive "split" approach used insofar (in V1,V3 etc). Now ... the C# that does this is classified strictly as internal ... but I guess that I could remove some sensitive functions.

BTW: Brep Lists would require some "major" changes in the tree(s) management - the ultra boring bureaucratic part of programming.

Working with just one Brep (preferably closed AND valid) is the easiest of things (thus a V3A build would emerge first). 

BTW: As things are (case random slices) IF the box is "flattish" (i.e. smallish Z domain) use the x,y dirDirection option (as shown/explained above) > that yields pieces kinda the ones due to a randomly broken "thin" piece of something (but the cuts are still straight - maybe some more realistic user options are required here).

A bullet effect option (using a proper Magnum 357, that is) is under consideration as well. A Morph (or a Maelstrom) capability could do some WOW stuff.

I've actually already got the flattish box simulation working! (huzzah!) but thanks for the tip!

As mentioned dont worry about the Breb list, the cube is fine for me to work with! Bullet effect option sounds pretty epic as well! Unfortuantely I need to come up with something for Monday so might work with the previous version you mentioned above (with the cracks if you were able to upload it before then?)  and then progress into to Magnum 375 recreations :)

Love the mouse!

H

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