Grasshopper

algorithmic modeling for Rhino

I made a python script that estimates the direction of drainage paths on a surface.

It does not deal with puddling or accumulation, and if you have any suggestions on how to make it faster or to improve it in any way, let me know -- this is a first draft.

 

you can see the python code in this github gist:

https://gist.github.com/1054969

 

 

 

Views: 42734

Attachments:

Replies to This Discussion

gracias!

I'm probably too late but i just read the last replies.

The VB code to make this work with a mesh object would be something like this:

 

Private Sub RunScript(ByVal pto As Point3d, ByVal m As Mesh, ByVal tol As Double, ByVal maxsteps As Integer, ByRef A As Object)

 Dim ptl As New list(Of point3d)
 Dim pl As New plane(pto, vector3d.ZAxis)

 While ptl.count < maxsteps
   Dim mpt As meshpoint = m.ClosestMeshPoint(pl.origin, Double.MaxValue)
   pl = New plane(mpt.Point, m.NormalAt(mpt))
  If ptl.count > 0 AndAlso pl.OriginZ > ptl(ptl.count - 1).z Then Exit While
  ptl.add(pl.Origin)
   Dim an As Double = vector3d.VectorAngle(pl.XAxis, -vector3d.ZAxis, pl)
   pl.Rotate(an, pl.ZAxis)
   pl.Translate(pl.XAxis * tol)
 End While

 a = ptl
End Sub

 

Note that since mesh welding affects the mesh normals it will also affect the drainage direction.

Thanks Vicente,
It's possible to compare VB net compoment for drainage système With surface ?
And maybe works to brep open, It's not complicated to update .

Thanks for your reply

Whaoo:

Hey Remy

I'm relatively new to Grasshopper, which seems opposite to most using this thread. I've attempted to replicate what you've achieved in the image above, as am trying to model the surface runoff on a site (which looks to be a great deal smaller to yours - in terms of mesh construction). I've used the VB script provided but seem to be hitting walls...(actually I've attempted all the definitions provided for Kangaroo & GH, but my lack of mastery is obviously letting me down).

Is it possible to upload your script for use?

I've also attached the terrain and script I've attempted to replicate.

Any help would be greatly appreciated.

AL.

Attachments:

Hi A.L ,

I do not know your level of rhino and grasshopper, but there are some things to include:


Your mesh constitute a set of sub mesh, as shown in the picture.
(I work with rhino in French, but the understanding is the same)

Your mesh is not topologically exact and is defined with millimeter rhino file(scale 1000 for VB component).

Then the grasshopper definition contains incorrect parameters.


Max-step should be set to about 1000.0.

Tolerance should be set to about 1.0.

That's what I've done:

Extract the mesh points, the outside contour and the break lines.

Create a mesh with RhinoTerrain.

I used component VB script for drainage script with original parameter name:

Every Go !!!!

Attachments:

Hi Remy,

thanks for sharing these files.

I had a look at this definition you made and applied it to my geometry... however I'd like the script to go on a loop using anemone.. any ideas how to do it???

thank you!

Genius!  Very handy, thanks much!

hi all,

is anyone able to elaborate on the method to achieve this with a mesh. I am a novice when it comes to writing code directly and cant seem to work out how Vicente's code is applied to achieve the results seen at the end of the thread. I have tried copying them into a VB script component but must be missing something. Is anyone able to post a definition that makes Benjamin's original drainage script work for a mesh terrain?

Many thanks

chris

I've created a GH + Kangaroo solution that works in a much looser method, but it can work with mesh geometry. See the example files here.

Hi sheet,

i figured it out with kangaroo already... but was after the scripted component because kangaroo runs very heavily and i want to run it across >50sq km of terrain with a grid spacing of 25m or less so a lot of calculations if done in kangaroo and very slow and clunky.

thanks anyway!

Hi Chris,

I think tracing around 80,000 points on a complex terrain mesh over many iterations is going to be quite slow whatever method you use.

However, using PullToMesh instead of CollideMesh will be considerably quicker than the method above, because it doesn't have to check for containment (also meshes are generally much quicker than surfaces).

Here's a definition using that, with around 40,000 points. It takes maybe 100 seconds to initialize the simulation, but then runs around 2 iterations per second.

I know in the past Kangaroo has slowed down with very large numbers of points, but I have been working on it. The latest version should be noticeably quicker than before, but of course there's still plenty of room for improvement...

Attachments:

RSS

About

Translate

Search

Videos

  • Add Videos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service