Hi everyone,
Today I was trying to apply multithreading to ghPython from what I learned of a video tutorial that I have just seen, but when I apply this script:
import ghpythonlib.parallel as ghp
import Rhino.Geometry.Point2d as Point2d
def ptsX(pts):
return pts.X
ptX = ghp.run(ptsX, pts, True)
it’s giving me this error and I don’t know why
Runtime error (ArgumentTypeException): expected Func[object, object], got function
What is pts?
Seems to work here if:
pts = [Point2d(0, 0), Point2d(1, 1), Point2d(2, 2)]
Also tried with a collection of 3d points to x (list access):
Hi Nathan
Sorry my bad, pts is a points’ list that have passed through the “Set” component (to eliminate possible duplicate entries).
I tried your script and it works perfectly … but when i tried to adapt it to my needs I have failed miserably. So here is what I´m trying to do:
- Import 3D point list from a text file
- Extract their coordenates (X, Y, Z)
- Convert them to 2D point list.
- Apply what I have learnt from a video tutorial about multithreading.
So when I applied your code it worked, but when ever I try to reference pts (point 3D list) I fail miserably and I don’t understand why …
Tried running through a set but it didn’t change anything. I’d have to see how pts is being generated to suggest anything else.
Hi Nathan,
Thank you for replying and sorry if I was late, I think the I have just pinpointed the error.
See the first comment since that is what I intend to do next,
grasshopper3d.com : GhPython BooleanDifference Multi threading
Hi Nathan,
Here is a sample of the expected items in pts:
{463578.31, 8.0621e+6, 335.614}
{463570.355, 8.0621e+6, 334.853}
{463558.771, 8.0621e+6, 334.569}
{463546.948, 8.0621e+6, 333.58}
. . . etc
All the problem that I had was that Grasshopper’s Parallel module needed a list to work.
So the new script is:
import ghpythonlib.parallel as ghp
import Rhino.Geometry.Point2d as Point2d
ptslist = pts
pts2D = ghp.run(Point2d, ptslist, True)
So @nathancoatney , if you known another way to improve my script I will gladly hear it.
1 Like