Grasshopper

algorithmic modeling for Rhino

Hello,

I am trying a simple test of the new Python Module with this simple code and getting a list of null's as output:

import ghpythonlib.components as ghcomp


curves = ghcomp.Voronoi(points)

the input for the component is set to Type Hint--Point3D  and Item Access...any thoughts on why I am not getting any valid output?

Aaron

Views: 1354

Replies to This Discussion

Changing to List Access works!

But...I can't get it to work if I copy Steve Baer's example and use this code:

import ghpythonlib.components as ghcomp
import ghpythonlib.parallel

#custom function that is executed by parallel.run
def Voronoi2D(point):
result = ghcomp.Voronoi(point, rect)
if result: return result.curves

if parallel:
cells = ghpythonlib.parallel.run(Voronoi2D, points, True)
else:
cells = ghcomp.Voronoi(points, rect)

a = cells

I am getting a list of Nulls when parallel is set to True...it works when set to False

Any thoughts?

AA

Hi Aaron,

Apart from supplying the "rec" (rectangle) as your second argument in ghcomp.Voronoi(), whereas actual second one is cells radius and third one is boundary(your rectangle) - the problem seems to be with the very nature of how Voronoi algorithm works - it creates cells by taking a list of points and calculating intersections of their half-spaces.
Let's say you have dual-core. What you seem to do with parallel module is to provide a single point to the first cpu - which results in "None" (Null in grasshopper) as ghcomp.Voronoi() could not make a Voronoi cells diagram out of just one point. Then you pass the second point to the second cpu - same thing happens. Then you pass on the third point to the first cpu - again "None". And so on. In the end you are getting a list of "None"'s (that is "Nulls in VB.NET) which equals the number of your input points.

So basically your code will work if you would provide a list of boundaries (rectangles) as an argument of the ghpythonlib.parallel.run() function instead of list of points. In that way parallel module will take a list of all points and a single boundary and assign it to one cpu - which will produce a list of voronoi cells for that boundary. Then take the whole list of points again and second boundary and assign it to your second cpu. Etc.
Btw, I have been puzzled with this issue too.

Please attach your files for future questions.

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