3d Voronoi in grasshopper

3d voronoi qhull dimitrie stefanescu

 

Deprecated. There’s a new version here.

More as a scripting experiment, when i was mucking about trying to make the delaunay triangulation work in grasshopper i somehow found the wonderfully complex qhull library which i promptly set to push and pull to get it to work with grasshopper. As advised on their website, the best way to do it is to call it as an external program, which is exactly what i’ve done:  no files are written or read, no dos windows pop up, everything’s smooth.

Given that you don’t have many complex operations in grasshopper after the solution is generated, you’ll be able to handle quite an impressive amount of points (say 200 on my three-year old toplap) in real time. If you add the simple planarSrf operation, then say 60-70 and it gets sloppy.

What you’ll need to do to get things rolling:

0. Download the 3dvqhull definition and example file, and remember not to use it for commercial purposes, share-alike whatever you do with it and take the time to give the proper credits:  🙂

1. Download qhull, and unzip it in a folder of your choice.

2. Get going and search for “System.dll”. What you’re interested in is the 2.0 version which you’ll usually find in here: “C:\WINDOWS\Microsoft.NET\Framework\v2.0.5[…]\”. If you can’t find it, I’m amazed grasshopper works for you. Anyway, you can find and install it from here.

3. Add the newly found System.dll version 2.o as a referenced assembly of the qhull component in the definition file.refass

If it turns orange, it’s cool.

4. Write in the panel that is linked to the “path” input the full path to the qhull program qvoronoi. You don’t need to add the .exe extension, but you can do it if you feel confortable.

pathh

5. There’s just one more thing you should know: facets that contain the infinite vertex are omitted altogether, without remorse. So as to have as little facets tending towards infinitum, I always add the corners of the points bounding box to the input sites.

bbx

You can scale the bounding box in respect with its center, or you can just call the whole thing off – it’s your choice.

I think this just about covers everything. Take care and have fun.

didi out.

PS: Qhull does more than voronoi. So if you have the time to explore and test, please do – the package is very powerfull and it can be used for more than this.

Advertisements

110 thoughts on “3d Voronoi in grasshopper

  1. Nice work. I was so excited when I saw this, that I immediately wnated to try it out. Unfortunately the ghx- file is not read properly in gh, it prompts some 32 messages at first and then shows a cluster that, when exploded is empty.
    Do You have an Idea what the problem seems to be?
    Cheers, and keep up the good work

  2. hi dimitrie,

    i’m extremely new to grasshopper… in fact, i’ve just downloaded it to give this a go. i’m receiving an error at the bottom of my window saying “All curves failed to load…”. Any idea what may be causing this?
    Also, if you could recommend a good place to learn more about grasshopped it would be much appreciated. Thanks.

    • i have no idea. maybe check you have version 0.6 rev 12+ but if you say you just downloaded it this is probably not the cause. maybe you can mail me the rhino file and the definition file so as to peek in them if i have the time.

  3. Cheers for the immediate reply,
    everything works great!!!
    Now the fun can start!
    Thanks again, I’ll keep u posted on my progress.

  4. Hi,

    Thank you for this wonderfull definition!
    I was trying to achief something similar…but I gave it up, because it took to long 🙂
    The only problem I have, is that I don’t quite understand the cluster object…
    I would like to grow the structure inside a specific geometry…not in a bounding box.
    Do you know how I can do this ?
    Thx

    • hello nino,

      the bloody cluster just adds to the pointlist the 8 vertex of the bounding box of the point to have as little facets with vertexes@infinity floating around (this way you only get 4 cells that contain the infinity vertex, so the facet number is limited.

      Depending on what you want to do, you can take the vertexes of your enclosing geometry (mind you not a perfect sphere or it will fail) and add them to the point list and see what happens or, so as to get similar results to the pointset reconstruction tool you can remove the cluster object and then perform some a boolean intersections so as to cut out any cells or parts of cells that are outside your specific geometry. unfortunately this is highly computationally expensive, so try it at your own risk…

  5. Thanks a lot for the very fast answer!
    I’ll give it a try!
    I’m an architecture student and I’m hoping to be able to use it in my final design.
    I’ll let you know what my final outcome will be!
    Your work is really inspiring, can’t thank you enough!

  6. Hello

    Recently tried to open the .ghx file and it comes up with a “IO has generated 32 messages would you like to see them” prompt.

    I have the latest Grasshopper ver.

    Any suggestions?

    Thanks,

    CP

  7. Hi,

    when I tr to use it, I get the error
    “access denied”, related to the qhull files.
    Any ideas?

    • are you sure you have the right access permissions for the qhull files/folder (read at least)? otherwise i can’t say. maybe your antivirus is blocking this, but this has a very remote chance of happening.

      • in the output window the following text is to read:

        -The using directive for “System” appeared previously in this namespace Script
        -exception: Zugriff verweigert (Acess denied)
        –qhull start–

        • you can ignore the first warning (it’s nothing important).

          the access denied problem i’m afraid i can’t control or tell what to do with it.

          please send the file over, and also check your permissions (maybe the qhull folder is protected somehow).

  8. Hello, problem is the last version of grasshopper.
    Here, in france last version is 0.5.0099 so your script doesn’t work.
    I think that for us residents the last version is : 0.6 rev 12 as you say.
    So we have to wait for new version

    thierry

  9. I’ve been trying to call the Qdelaunay and can’t seem to get it to work. Any Suggestions? It can’t be as simple as replacing the file in the grasshopper definition…

    • hello brandon,

      calling qdelauny requires a new parse function for the output. please refer to qhull manual for an exact description on how to call qdelauny properly and get the right kind of output (which differs completely from what qvoronoi throws out with the included options).

      It shouldn’t be hard, but it will take some trial and error style coding since debugging in grasshopper is like playing darts while being blindfolded during a small earthquake.

  10. hi dimitrie,

    i’m a beginner in rhino, how can i get the holes, after generating the surfaces? thanks for your answer!

  11. hi dimitrie, thanks for sharing, one beginner question again, after i be able to achieve what u did in the image at the top, the geometry is basically planar surface from the definition, so how do i give them thickness and smoothen further?

    thanks

    • extrude them for thickness, fillet them for roundness. proper smoothing of surfaces is quite difficult in gh since the only way possible would be via scripting nodes which can prove quite a hassle… depends on what you want also.

  12. HI MY NAME IS DANIEL I´M ARCHITECTURE´S STUDENT, DO YOU HAVE SOME INFOMATION HOY TO CREATE A 3D VORONOI INA CURVE SRF, THAT IS FOR A PROJECT OF MY UNIVERSITTY FOR AN AIRPORT.
    THANKS A LOT.

  13. So, I am trying to work with your GH script ..But I receive such a error message ..
    0 The using directive for “system” appeared previously in this name
    1 script exception:Access Denied

    Could u help me to resovle this problem ?

  14. I’m trying to work with your ghx code, but
    it is quite strange shape.

    When I use point reconstruction set by McNeel, its output is box shaped.

    But your ghx code generates diamond like shape.

    How can I obtain voronoi shape (box-like shape) with your ghx code?

    I think real-time point manipulation is quite good!!!

    • well, pointset reconstruction was doing some very expensieve boolean operations to get stuff inside the box (basically cutting out everything that was outside) – you can’t do that yet effectively inside gh.

      bake and cut is the only solution i can give you for now.

  15. Hi, thanks for this little tutorial, I’m all new to this parametric world and this is verry helpfull !!
    Verry nice blog actually, I’ve been around it and I really like the urban bacteria, really interesting work!!

  16. Hi Dimitrie, this is a great definition. I just have a somewhat beginner question. It seems like I can’t really bake the generated curves. when I highlight the curves and click bake, nothing happens. Do you have any advice for this? Thanks!

      • Thanks for your quick reply Dimitrie! I am trying to bake the component labeled “curves” that’s attached to the D output of qhull and nothing is showing up when I click on it and then bake.

        I find that if i feed the “curves” node into the Planar component (instead of the poly), I can then bake the generated surfaces themselves, but that doesn’t really give me the curves. should the “curves” component be fed into something else?

        • update: I think I figured it out. I outputted the curves to a planar node then took the two outputs (from polygon and curves) and trimmed one from the other and baked that. It seems to be giving me what I want.

          Thanks again for your help and let me know if you would have done it differently.

  17. Hi Dimitrie.. I’ve been working with your 2d voronoi definition lately and making some extrudes with attractor points, and its been working great for the aproach I’m looking for.. but I’ve only been working for several weeks and I don’t know if I can render something out of grasshopper directly, or how can I render any model, or maybe I’m going the wrong way, do you know any tutorial I can look for? or what do you recomend me to do? Thanks!

  18. Hi man, thx for this work, would be consider for the gh developers for next releases. I’m researching the voronoi parameter in architecture, and, your definition appear the best interest way. But I’ve a problem, Can u help us for the people that so show the message: “script exception: Acces Denied”.
    I’ve thinking it should be, for that i have updated my system until Framework 3.5 (not only Framework 2), or I wrong and the qhull would work right anyway.
    Please discuss about

  19. how do you get the ‘referenced assemblies’ window to come up? sorry, somewhat new to code…so i can’t follow where the window is coming from.

  20. hey dimitrie thanks for great work you have done. I am attempting to delete the reference points from the example file and input new ones that I specify but I’m having some trouble getting it to display the new 3d voronoi based on those points. I was just wondering how I might alter the script so that I can use my own points. Thanks so much.

  21. sorry, one more question: I’m just starting out in Rhino and GH and have more experience in 3ds max so I was thinking about exporting the file so that I can make further alterations in that program. Have you done this or do you work exclusively in Rhino? Whats the best way to go about it? Any suggestions would be really appreciated. Thanks again for sharing all of this, very exciting stuff.

  22. Ey Dimitrie I just can´t acoplish to instal de Qhull i got stuck in step # 3. Add the newly found System.dll version 2.o as a referenced assembly of the qhull component in the definition file.
    Where is these REFERENCE ASSEMBLY? is it on GH? or in C:\Program Files\Reference Assemblies? I am kind of confused need more details tnks on your reaserch

  23. Hy there again, sorry but I don’t know wich scripting component to use, and does it says literally reference assembly in its context menu? tnks again

  24. Hey Dimitrie! whats up.. I already started working on your 3dvoronoi qhull, but I wanted to create a more rigid boundary, I dont know if thats possible..
    Maybe its something about what you wrote above “So as to have as little facets tending towards infinitum, I always add the corners of the points bounding box to the input sites.” but I didnt get that clear enough to try something that works.. I dont know if I could send you the .3dm with the points and a jpeg of some idea of what im looking for..
    thanks man..

  25. Hi Dimitrie,

    have to say really amazing stuff here. just wondering what I can do to get the ‘in between surfaces’ which you’ve got in that image above, cos all i’ve got are whole facets (is that what you call them?) within the ‘holes’ cut out. please help!

    • offset the curves and then create a planar surface from the original curve and the offset one. don’t forget to offset them in the same plane as the original curve (you can get that by using the planar comp)_

      • Hi Dimitrie,

        Thanks for that. I’ve managed to offset the curves (b ouput from the qhull), fillet them, flatten, merge and then connected that to a planar comp… and it works! BUT for some reason only for up to about 5-8 points within the point cloud. If I’ve got a large number of points (say 20-30) it doesn’t work any more.

        Also I’ve made planes from the d qhull outputs and b outputs, then used a diff comp to get the ‘in-between-surface’ but somehow it turns orange when i have many points. it works with just a few points. Any advice?

        • Hello there, I really don’t know what to say- we can start with a quite important question: which version of gh are you using? This def created a lot of problems for a lot of people, depending on gh vers, windows vers, etc

          • I’ve got gh version 0.6.0019. windows xp. can’t seem to figure out what I’m doing wrong because it works perfect for a small set of points – but theoretically it should be able to process quite a lot more? In fact, your image above seems to have processed quite a few points.

            This is what I’ve done:

            As you can see, the diff and planar comp is orange. Is there a limit to the number/type of points inputted into the gh definition? I’m at my wits end.

  26. Hi I am trying to understand how this works (great definition by the way)

    I don’t get why there is a bounding box in it, can I get a clue?

  27. I wanted to take the time and thank you. Your work as been an inspiration for my experiments in use of minimal surfaces i did in a shadow study on lighting. Thanks for the qhull script and keep up the great work.

  28. Hi Dimitrie, first of all, thx for your job, it’s really amazing!

    I’m begining with GH, and i’ve played your 2DVoronoi definition, really cool! So I tried to test the 3DVoronoi Qhull, but then a problem happens: seems like Qhull can’t import system.dll.

    The path is OK, but the source says: “/Import failed for ‘C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\System.dll’: No se pueden cargar uno o varios tipos requeridos. Recupere la propiedad LoaderExceptions para obtener más información.”(sorry, it’s in spanish)

    I’ve tried to re-install .NET framework, but doesn’t solve the matter. ¿Any idea?

    Waiting for reply & sorry for the bother. THX!

    • Hello,
      I solved the problem in gh 0.6.0057 something (the latest version available) by un-referencing the system.dll. The c# comp was originally referencing an older version of the .net framework and that’s why i had to reference the new one manually – now it’s fixed and you get a duplicate referenced file.
      So right click, referenced assemblies, select and remove…
      Bug me again if it’s still not working…

      • Hello, thx for the quick reply.

        Finally, problem solved.
        As you said, it seems to be a previous referenced assembly, and it loaded the problem. Just unreference and it works nice. Really Cool!!

        But I noticed another problem. I downloaded the latest qhull version (2010.1) and tested, but it doesn’t works anyway. When I test QHULL-GO on command prompt works fine, but if I type qconvex it misses a file called libgcc_s_dw2-1.dll

        Finally, I am trying to “voronize” a lofted surface, but not only to project voronoi poligons on the surface, instead of create planar facets. Any suggestion will be appreciated.

        A lot of thanks, and get on with your works. Those are really inspiring.

  29. Hi Dimitri,
    first i want to say thanks for share your great work.
    I am a beginner with grasshopper and scripting and i was wondering if exist a easy way to get each vonoroi region in a closed brep surface ? by this I mean to have the output of the algorithm as a list of solids and not a list of surfaces?

    cheers
    Riccardo

  30. Hi Dimitri,

    Im having a problem with the referenced assemblies..whenever i reference the system.dll file it comes up as
    ‘error: An assembly with the same identity ‘System, version = 2.0.0.0, Culture = neutral, PublicKeyToken=bb7a5c561934e89’ has already been imported.Try removing one of the duplicate references, (line 0) ‘

    but when I got back to referenced assemblies – there is only one option and when I remove it, I get ‘error: The system cannot find the file specified (line 0)’

    Im using an updated .net framework – V3.5 but cant find system.dll file in that folder – so Im still trying to reference the file from v2.0.5 – any ideas?

    Thanks
    Adam

  31. Hi, just trying to get this going, but get this error “index was outside the bounds of the array (line 138).

    This sounds like a problem with ‘scale’, but I am not sure what scale you guys mean by this.

    Thx,
    Hiaz

  32. A number of us are having the same problem with Referenced Assemblies as Adam (‘error: An assembly with the same identity ‘System, version = 2.0.0.0, Culture = neutral, PublicKeyToken=bb7a5c561934e89′ has already been imported.Try removing one of the duplicate references, (line 0) ‘. Ditching the referenced assembly gets: ‘error: The system cannot find the file specified (line 0)’.

      • hi
        i have the same problem as brian…
        i’m using grasshopper 0.6.0059

        if i edit the source of the qhull component i find in line 21:

        //Import failed for ‘C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\System.dll’: Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information.

        hope you have an idea how to fix this problem…
        greets
        tom

  33. hi,
    We are student in architecture in france and we have a really big workshop about fluid and flesh architecture, we are working on a frozen shape and we really want to used at the base your voronoi 3D i’ve tried your definition but i can’t referenced assemblies qhull with the system.dll it doesn’t work and still stay red. When i open your definition i’ve 5 errors mess so maybe the definition you have post was create with the old version of grasshopper ? we currently have the latest version 0.6.0059
    Do you have a solution ?

  34. Hi,
    Thanks so much for this, it truly is helpful and inspiring,
    I’m just having one problem. After following all the steps, the planar box is still orange with a warning saying all curves failed to load, and the output panel has an exclamation mark on it. How do I fix this?

  35. Hi,
    its really amazing to see this level of commitment and expertize.. I hope it gets you far!
    Only one small problem here! I did everything by the book but the 3rd mean component stays orange, and so does the planer component in the end.. any ideas??

  36. hi,
    Many thanks for your work.
    I’m a little bit confused by the final output.It said that i got a 4-d voronoi instead of a 3-d one.How can i get a 3-d voronoi?
    waiting for reply and thx a lot~~

  37. Hi,
    I just found this in perfect timing!! I’m an industrial design student here at University Of The Arts in Philadelphia and am working on some thesis work. A few of the projects are about using sound data to produce tangible objects. (of course there is much more theory, research and concept behind this)

    For one of the concepts I’ve been looking for a way to show a tetrahedronal-based structure where each module represents one key on the piano. I am not a programmer and have just started to learn about GH but do have some knowledge of Rhino. This definition seems like it could help me to express the concept. Here’s a pic of a rough sketch model I made- http://www.facebook.com/photo.php?pid=11782233&id=770315281

    I’m having 2 problems though…I’ve followed the instructions and it won’t work 😦 The QHull object did change from red to grey but not orange. I’m using the latest build of GH so maybe there is just something simple to change? Also, is there a way that I could cut each section at mid-points and set one common thickness at mid-point? The end goal is to 3D print these modules and let people “build with sound”.

    Thank you so much for your help and posting this definition!!
    Matt.

  38. Hi dimitrie,
    I have tried your definition, I dont have any errors in any of the components, but whats comes out from the qhull is always null.
    any idea how to solve that?

  39. Hi dimitrie, I had the same problem as steen, “all curves failed to load”, and noticed that you had already found a solution. If you could help me, maybe you can post it, I can send you the file gladly if you require. Thanks!!!

  40. hey dimitrie
    first thx for the nice pipeline
    anyhow we got a little last issue on the
    qhull\qconvex version.

    basicly we try to make knots for any number of lines which already works pretty well but every once in a while
    we get the followiong error —-
    error: input string was not in a correct format. (line:0)

  41. We are using grasshopper, but we are very very new to it. We downloaded the voroni file, however we are having trouble attaching our surface file to the voroni file. If you could let us know that would be great. Two blondes being clueless.

  42. hi dimitry
    I am working on a architecture project, and we are really interesting in the 3d voronoi diagram. I am completely new in grasshopper, but when i try to open your, i can’t use it. It say that i have import system.dll twice, except i don’t. (it was allready ike that when i open. )
    whatever i do, the box stay red.

    I really need to understand how to this, quickly.
    any ideas?
    thks

  43. Hi Dimitrie,
    Thank you for posting this!! I keep getting an error in the source:
    //Import failed for ‘C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\System.dll’: Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information.

    Any insight? Thanks a ton,
    Doug

  44. HI dimitrie stefanescu, nice work!! i dont speak English but i can try.
    My problem is: when i open the definition to voronoi 3d, i see text like “Import failed for ‘C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\System.dll’: Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information.” and others message like Adan, i dont now what to do. so the definition dont work.i have gh 0.6.0059. and win xp, you can help me? i realy need this tool!! a hug!!

  45. hey dimitrie
    great work!

    i cant get my file to work.
    mean
    mean
    mean

    and
    planar are still orange.
    and i got an exclamation mark on my out window.
    i tried for 7 hours now and i am going to freak out.
    hope you can help me.

    best wishes from munich

  46. Hi Dimitrie,

    Your work is really impressive and this small tutorial has been really helpful to understand the voroi structure. I am trying to use your version Voornou3dancQConvex with no success. I replace the location of the qhull files and made sure the assemblies were done with System.dll, and still I get Surface box orange. Can you give me a hand? Thank you

  47. Thank you Dimitry for this wonderful work. I apologize, I am new to Ghopper. I have successfully installed everything as mentioned above, however, I am not sure how to perform STEP3: “Add the newly found System.dll version 2.o as a referenced assembly of the qhull component in the definition file.”

    How can I “add a referenced assembly”.

    Thank you for your input!

    PS. by the way, there are several verions 2.0…4.0. It has to be 2.0, correct?

  48. hi ,
    I am very new to grasshopper , i have done with tutorials explained on grasshopper website, now i wanna learn voronoi script , i have downloaded many definitions but none of them is working for me …. actually when i opens it … it doesnt says nything neither shws nythin to bake …. m not exactly wht this does???.. coz whtever i do …nothing get changes ,, m using windows 7 64 bit ….. i can only see tht bounding box to scale ….. then i drwned some points in rhino and i seeded them to starting point component … and thn a bounding box comes… and after tht if do nything nothing gets changed.. m playin with it frm 3 hrs …. reading this blog n all … m still struck to door … m really eagerly waiting to open tht door of wonderful world of voronoi ….. waiting for reply

  49. May I simply say what a relief to discover someone who really knows what they’re discussing on the net. You actually realize how to bring an issue to light and make it important. A lot more people must check this out and understand this side of your story. It’s surprising you are not more popular since you certainly have the gift.

  50. Sorry Dimitri, I love your work and admire what you do or for that matter, anyone who can comprehend anything algomorythmic (being a dyslexic doesn’t help with this sort of thing but I’ll keep at it till I see something on my screen to get creative with) I’m struggling with step 5 in your procedure. The ‘bounding box verticies add’ component in your diagram has confused me – for I don’t recognise the component or configuration. Any ideas?? By now you’ve probably guessed I’m an absolute newbie to GH but any advice or explaination on this step would be greatly appreciated,
    Kind regards,
    Dave

  51. I like the valuable information you provide in your articles.
    I’ll bookmark your weblog and check again here regularly. I’m quite certain I’ll learn lots of new stuff right here! Best of luck for the next!

  52. hi, great job!
    i have a question about it, because it doesn’t run, i have the lastest version of grasshopper and when i open the file gh some commands have the script ”OLD” on the name and also are orange. ”mean”
    I have tried to modify all the definitions searching in the program but at that point the last command ”boundary surface” doesn’t work, how can i do?

    Thanks in advance

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s