Grasshopper

algorithmic modeling for Rhino

Hi All.

I have just started learning grasshopper and I find myself in need of 'steering' by someone who has some idea of what they are doing...

I am looking at using Rhino to draw the water table under the ground based on pressure monitoring data available over different dates. 

In essence, I want to morph between two surfaces to show seasonal movements.

The picture below shows a hypothetical 'two surface' model - the red points in-between the two surfaces are where I have got to so far (the distance between surfaces is controlled by a slider):

Having got this far I was feeling quite proud for half a days work having never before used grasshopper ... HOWEVER - I am now stuck.

To get to this point I:

A) Divided each surface into 100x100 intervals.

B) Drew a line between each corresponding point in each surface.

C) Extracted a point from each line using a percentage of length (0-100% being from surface no. 1 to surface no. 2)

I have since tried:

1) Creating polylines with each row of data then lofting = failed

2) Creating a mesh from the points using a plugin = failed

3) Directly merging between the two surfaces using an algorithm put together by someone smarter than me (credit of this site) = failed because the number of vertices were different between the two surfaces.

I am really hoping someone can guide me on this as I am really at a loss about where to go from here.

Thanks in advance.

Lyndon J

Views: 5257

Replies to This Discussion

Hi All.

I got it working. My version was extremely slow, splitting each surface into equal segments drawing lines between segments, selecting the % difference between surfaces, turning into pointes then meshing...

I adapted another members work (cant find the link now!) and got it working smoothly. This method 'appears' to use the faces from the first mesh and apply those to the vertices of the second mesh... 

Anyhow - please feel free to comment if there is some way I can improve :)

Merry Christmas Lyndon, and Congrats!, was real happy to read you have your definition working, especially one performing a Morph. It is! a great feeling to absorb such empowering skills, but especially in Grasshopper! :)  I also am creating a blend between multiple imported surfaces, all of which will have slightly different numbers of vertices.

1) if it was Manually, how did you draw a line between each corresponding point in each surface?, or did you use Ln(line) component to connect them all?


you also wrote: "..got it working smoothly. This method 'appears' to use the faces from the first mesh and apply those to the vertices of the second mesh..."

2) this sounds great, is it like retopologizing the 2nd mesh based on the 1st?, perhaps equalizing vertex numbers, positions and properties prior to SDivide and morphing?


I hoped you could let me know,..

2) is it possible to manually draw a few "key" Lines connecting points, that would then cause(influence) SDivide & Ln to create lines between points at their correct correspondence between surfaces?

My surface imports to Rhino as multiple sub-surfaces which are opened in Grasshopper using Srf > Set Multiple Surfaces. But in this case when i then use SDivide and Points on Surface the points are created at the intersections of each sub-surface and then across them instead of being Equally distributed as on a Single surface.

3) is there a way to import or join my sub-surfaces into a Single surface that SDivide will then distribute points evenly over?, perhaps Brep > Join?

Please excuse my enthusiasm if asking to many questions.

Thanks again for any help soon as you've moments,
Jeff


Hi Jeff.

My apologies for the late reply! I was off over the Christmas break and only just back in the office this morning.

 

I would like to start by saying, I am no expert - but happy to provide my thoughts none the less. If anyone else with more experience would like to chip in please feel free!

 

1) if it was Manually, how did you draw a line between each corresponding point in each surface?, or did you use Ln(line) component to connect them all?

 

I used the Ln component to join vertices between each surface. As I was working with two surfaces I meshed each surface with an equal number of U/V divisions (Vertices) so was able to draw lines between each matching vertex.

 

2) this sounds great, is it like retopologizing the 2nd mesh based on the 1st?, perhaps equalizing vertex numbers, positions and properties prior to SDivide and morphing?

 

Equalizing is correct. When you mesh an object it will create vertices, and you can use these to re-create a mesh between each set of sub-surfaces. You don’t need to Sdivide after meshing. If you check the definition in my second post you should get the idea.

 

2) is it possible to manually draw a few "key" Lines connecting points, that would then cause(influence) SDivide & Ln to create lines between points at their correct correspondence between surfaces?

 

This I am afraid I cannot provide concrete guidance on this. I am sure it is possible by drawing lines then matching vertices based on position relative to the ‘key lines’ however I don’t feel this would be a great solution. Better to create something that is more automatic.

 

My surface imports to Rhino as multiple sub-surfaces which are opened in Grasshopper using Srf > Set Multiple Surfaces. But in this case when i then use SDivide and Points on Surface the points are created at the intersections of each sub-surface and then across them instead of being Equally distributed as on a Single surface.

3) is there a way to import or join my sub-surfaces into a Single surface that SDivide will then distribute points evenly over?, perhaps Brep > Join?

 

Yes, you can use grasshopper Brep-join to join your sub-surfaces before you divide. See image below. Alternatively, if you are joining matching sets of sub-surfaces then you can morph each sub-surface with its corresponding sub-surface then join the whole object.

 

 

If you can upload an image of what you are trying to do I may be able to help more. My work evolved to some degree since I made these posts. I am now generating objects based on time stamped data from excel rather than objects in Rhino.

 

How many sets of surfaces are you trying to merge through? It is also possible to morph from 1 to 2, 2 to 3, 3 to 4 …… x-1 to x by using a slider which calculates the range and picks the correct two surfaces to morph. If you need more info let me know and I will write something.

 

I am planning to show some of my work and where my industry (civil engineering) is going with grasshopper based solutions. Will post a link shortly to some of my projects.

 

Cheers

Lyndon

 

Good Morning Lyndon,

really appreciate your generous reply,.

My apologies for the late reply! I was off over the Christmas break and only just back in the office this morning.

- ..no probs of course, hope you'd a Merry one,.     


    1)
I used the Ln component to join vertices between each surface. As I was working with two surfaces I meshed each surface with an equal number of U/V divisions (Vertices) so was able to draw lines between each matching vertex.

- ..by "meshed" i assume that meant converting Surfaces with MeshUV\DeMesh?, and from your screenshots thats a substantial number of vertices and therefore lines to draw, well worth it though from the results!, i agree with your answer to 3) that a more automatic solution is required,.    


    2)
Equalizing is correct. When you mesh an object it will create vertices, and you can use these to re-create a mesh between each set of sub-surfaces. You don’t need to Sdivide after meshing. If you check the definition in my second post you should get the idea.

- ..thats great news, equalizing vertex numbers is exactly what i need to do since my Blend surface "keyframes" by nature will likely have unequal point counts. However,
a) ..when using default Rhino surf's your intruiging def. starting to work for me only after i replaced you "custom" Domain(VB\Python?,let me know) with Deconstruct Domain. then it connected each surf's vertices but did Not produce an intermediate surface or points.
b) ..when using my IDENTICAL Blend surf's in your def. with Deconstruct Domain and Merge comp's it then produced intermediate vertices,.
see def. screenshots or i can send def's i you like,.

I'll also produce the 2nd, Non-identical Blend surf keyframe to test in your def.

- 5) please show me which actual Domain etc. components or substitutes to use and how to use them to run your def. successfully?



    3)
This I am afraid I cannot provide concrete guidance on this. I am sure it is possible by drawing lines then matching vertices based on position relative to the ‘key lines’ however I don’t feel this would be a great solution. Better to create something that is more automatic.

- .. agreed, 6) does or will your latest def. contain more automated, vertex correspondence, Ln creation?
     

    4)
Yes, you can use grasshopper Brep-join to join your sub-surfaces before you divide. See image below. Alternatively, if you are joining matching sets of sub-surfaces then you can morph each sub-surface with its corresponding sub-surface then join the whole object.

- ..perhaps i missed something, but after using Brep > Join on my polysurface SDivide still saw it as subsurfaces instead of a single surface,.     

     

    If you can upload an image of what you are trying to do I may be able to help more. My work evolved to some degree since I made these posts. I am now generating objects based on time stamped data from excel rather than objects in Rhino.
- ..see screenshot "2-Def_shot.JPG" showing my two surf's beside Blended Rhino surfs which i need to do with mine,.
     

    How many sets of surfaces are you trying to merge through? It is also possible to morph from 1 to 2, 2 to 3, 3 to 4 …… x-1 to x by using a slider which calculates the range and picks the correct two surfaces to morph. If you need more info let me know and I will write something.

- ..that sounds perfect, esp. since the sets of surfaces will be as nearly unlimited as the feature film they're modeled from. Yes, i'd love to learn more info\def's on this subject, thanks,..     


    I am planning to show some of my work and where my industry (civil engineering) is going with grasshopper based solutions. Will post a link shortly to some of my projects.

- ..look forward to that as well, please keep me informed,..

I should be available most of today and days following so really look forward to heard back soon as you've free moments.

Thanks again for the great work as well,

big fan, Jeff

Attachments:

Hi Jeff.

No worries, I am in Australia so I am not sure if you will get this on your ‘today’ or ‘tomorrow’

I answered some of your queries to Dave below, in another post.

 

For these questions:

- ..by "meshed" i assume that meant converting Surfaces with MeshUV\DeMesh?, and from your screenshots thats a substantial number of vertices and therefore lines to draw, well worth it though from the results!, i agree with your answer to 3) that a more automatic solution is required,.   

1)      By mesh, I should have said produce a surface – then convert surface to mesh – followed by de-mesh to get access to vertices etc.

 

You can reduce the resolution of points if you need to, depending on your hardware. The more points you use the harder and it is to compute a solution, however the more points you use, the more accurate your interpolated surface. You need to find your own balance between speed and accuracy.

 

- ..thats great news, equalizing vertex numbers is exactly what i need to do since my Blend surface "keyframes" by nature will likely have unequal point counts. However, 
a) ..when using default Rhino surf's your intruiging def. starting to work for me only after i replaced you "custom" Domain(VB\Python?,let me know) with Deconstruct Domain. then it connected each surf's vertices but did Not produce an intermediate surface or points. 
b) ..when using my IDENTICAL Blend surf's in your def. with Deconstruct Domain and Merge comp's it then produced intermediate vertices,.
see def. screenshots or i can send def's i you like,.

I'll also produce the 2nd, Non-identical Blend surf keyframe to test in your def.

 

2)      I am not sure what you mean by my ‘custom domain’ are you referring to the definition in my second post – or the post I sent for David to look at? Perhaps you can circle the component and upload a screenshot so I know what you are referring to? Your second screen shot appears to have worked OK


- .. agreed, 6) does or will your latest def. contain more automated, vertex correspondence, Ln creation?

3)      No, I moved away from morphing surfaces and moved my solution to generating surfaces based on point data. This cut out the requirement for me to generate the surface to begin with and allows very automatic production of surfaces from data out of excel. Perhaps this would also be a good solution for you? You could:

  1. Move your point data to excel, by exporting the x, y, z of your vertices for each surface.
  2. Use excel as your information repository then write a definition to interpolate between your start and end points from excel.

This is basically what I have done now, as I have 1700 different ‘surface’ snap shots from the data I am working with.

- ..perhaps i missed something, but after using Brep > Join on my polysurface SDivide still saw it as subsurfaces instead of a single surface,.   

4)      Sorry, perhaps I should have tried that – I didn’t get as far as trying to subdivide. There should be a way to then re-create as one surface if it is necessary… I will try and find out when I have time.

 

    How many sets of surfaces are you trying to merge through? It is also possible to morph from 1 to 2, 2 to 3, 3 to 4 …… x-1 to x by using a slider which calculates the range and picks the correct two surfaces to morph. If you need more info let me know and I will write something.

- ..that sounds perfect, esp. since the sets of surfaces will be as nearly unlimited as the feature film they're modeled from. Yes, i'd love to learn more info\def's on this subject, thanks,..     

 

Sounds to me like you might be better taking the excel read, interpolate route? If you have nearly unlimited surfaces, then they must be generated from some other data source yes?

 

Let me know your thoughts, if you would like to discuss anything I am happy to make myself available on skype at some stage to talk you through some of this stuff.

 

Cheers

Lyndon

 

EDIT: I have uploaded a video, which shows a surface generated using excel data - which basically loops between 'snapshots in time' to give you an idea of whether this would suit your needs.

https://www.youtube.com/watch?v=f9XAne9byQc&feature=youtu.be

 

 

Nice!, Excel's containing Contour\heightmap data? auto-surf's, your right, very interested.

- ..7) Might you have time for example def.,esp. interpolation def running from excel, and i'll try your instructions, vid's, pdfs are always great

..but your SurfaceMorph def's almost working enough to try with my different surfaces, perhaps we'll complete the last step below?

"2)      I am not sure what you mean by my ‘custom domain’"

- ..(attached) see your 1st posted def. screenshot "CODE.jpg" for your singular Dom with C,D and Out parameters i can't find in GH, but only VB or Python components possess that i could find,.


"..Your second screen shot appears to have worked OK.."

- ..cool!, good to know its mostly functioning properly, but when i Preview polygons a number are missing. The only difference is the Domain parameters. When i 1st used your def. vertex lines(Ln) were drawn but Blend points and surface appeared only after using Deconstruct Domain and Merge components. I substituted these cause there was no Domain with those param's in GH.

- ..8) and those are identical surfaces, i assume it still work if they had different vertex counts?, as would your current def. RE: 4 rows of data points..with differing numbers of points in each row.

Awesome!, thanks Lyndon,

Jeff

Attachments:

Hi Jeff.

You can export contour data as point data in X,Y,Z by dividing your contours then exporting resulting points.

I see the Dom you mentioned, I had not even realized when I made the post that it was custom VB. I found the old definition and the code was:

D = C.Domain.Max

Have a go and see how that works.

And no, unfortunately i don't think it will work with different vertex counts with this method. If you cant get away from having those different counts, then you may need to exclude the excess vertices that dont have a matching partner on the second surface, or find a way of matching them manually for each surface pair.

What is the end goal of your project? Are you trying to morph between different topographic maps? If so, for what purpose? Showing surface change in relation to a geological timeline? Or ... ?

Cheers

Lyndon.

P.s. if you are working with making topographic representations from contour data you may like to try the TJOA terrain mesh.

http://www.grasshopper3d.com/profiles/blogs/grasshopper-subsitution...

Very useful :)

Thanks Lyndon,

                      i'm a real green Grasshopper and haven't coded definitions yet,

9) how do i make a component of: D = C.Domain.Max ?

..really! to bad it won't work with diff. vertex counts, guess i initially misunderstood it did,.

when you replied, i left def's using RectGrid and Project components which worked mapping custom grid vertices to my surf's. Great promise but may not retain topology accurately. So guess i'll keep working that, excluding excess vertices (do you mean Data Matching or something else) and the excel read, interpolate route, esp. if/when you've time for assist and definition examples,.

the near end goal is feature film geometry blending, end application is quickest 2Dto3D movie conversions,

Looking forward to ExcelInterpolation,

Jeff

Ha ha,

No problem we all start somewhere. I was in your shoes 6 months ago.

My current definitions for interpolating excel data are somewhat complicated, so not the best example. I will try and get some simplified examples together for you. 

I have also attached my definition from the second post, which has the DOM component. Just double click the component to see the code.

Scripting is easy, you basically just write VBA code here:

All you need to do is substitute the *****WRITE CODE HERE**** bit with A = X.Domain.Max (note the A and X in place of the origianal C and D). And note the plus/minus symbols on the vb code block? These add or remove variables as required. I have some in my later work which have 4 inputs 6 outputs (See Mondays post).

Will get back to you ASAP with info on excel and how to interpolate data.

Attachments:

Hi Jeff.

Got a definition together for you to look at. You will need to download the three files, open the rhino file attached, load the GH file attached and set the PATH componant to whereever you save the demoread excel sheet. You will also need to download and intall TT toolbox for this to work: http://www.food4rhino.com/project/tttoolbox?ufh

This ones a bit rough, but should get the concept across. Have a good look through, play with it, change values in the excel sheet and see how it responds.

Ill answer questions for you tomorrow if you struggle getting your head around it :)

Cheers

Lyndon 

Attachments:

You found a good and light solution. Great work, especially just starting with GH!

Here is a slightly different approach that shows you how to build a morphed surface very lightly using surface from points. By setting "interpolate samples" to true, you also get a more even grid in your mesh. Also, I have included a second bit that shows a bit of how to use data trees to manage items in a single sequence of components. It's probably not necessary for this particular definition, but perhaps will open up some new avenues for you as you continue with GH. :)

Attachments:

Hi David.

That looks like a very neat solution. My work has evolved alot since I made my original post, so these methods may be very useful!

Which method is more computationally efficient? That is what I seem to struggle with the most.

Since my original post, i moved from creating surfaces and morphing them to generating surfaces directly from data in excel. I have been using the patch command, but perhaps surface from points would be more effective?

A few shots of what I am doing below: 

The model demonstrates the position of a water table, under an earth embankment dam. There are two surfaces, as there are two different kinds of rock under the dam and each appears to have its own water table. We want to monitor it to make sure the lower surface is not eroding (would manifest in a drop of the water table over time in one location - like a sinkhole).

This last is part of the definition where I am creating the surfaces. The code coming before (off screen) reads from excel, sorts and selects data based on a slider bar (I am looping through 1600 data sets showing snapshots in time of the water level under a dam) and then passes it onto the surface build. Only problem, is it takes about 1 second for each frame to be generated as you use the slider - so its only really useful to run an animation and compile as a movie.

Your thoughts here would be appreciated.


As noted in my previous post I will do a thread demonstrating some of my work, and where this might be used in the dams engineering industry. Will post a link here once I get time...

RSS

About

Translate

Search

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service