Create CPython components using Hops in Grasshopper

Thanks, i see this problem in another topic and i though it solved.
Actually i convert tree to one list avoid this error than i split it in grasshopper.
We can also create output list for length of lists in the tree than use it to split the flattened tree.

Input trees were implemented, but not output trees

@anon39580149 if its any help, I’ve been dealing with oupting trees in two ways:

  1. serialiazing the python nested list into a string with the json module, namemly json.dumps(), and after hops converting it back into a nested list with a ghpyhon component that deserializes it with json.loads()
  2. flattening the list in python, then passing also a length of each list in another hops output to regenerate the structure with the partition list GH component.

Either way has worked well so far, until those tree outpus in hops come around

1 Like

Thanks, i used the second method

I’m not sure how hard would it be to implement or what are your plans with CPython + Hops, but I believe that it would be really cool if there would be some way to make it more portable.

I mean it would be great to make it possible to create some sort of plugin with these Hops components, the plugin that could be released on food4rhino, and the user could easily install it and use it. Right now it’s already amazing, but for your own usage, cause you still need to run the code manually in VSC / Pycharm, and set addresses for Hops components manually.

Looking forward to see more :wink:

Packaging as gha is something I would love to implement, but it is still a ways off.

3 Likes

Hello guys,

First of all, congratulations for this amazing feature! I’m loving testing it.
During those tests, I came up with something I couldn’t figure:
What is the correct version to define in a pyproject.toml file?
I thought it was “1.4.0” but it didn’t work.

1 Like

@thomas.takeuchi Are you using poetry to manage the environment? Seems like you originally had ghhops-server @ 1.3.0 and then manually edited the pyproject file to 1.4.0
poetry throws the error that you see.

Run poetry update to update the poetry.lock file

1 Like

Oh That’s true!
I changed the version manually and forgot about it.
Thank you! Now it worked!

Here it is! Thank you for the callout @eirannejad!

Thanks for these development, inside compute and then hops, only beneficial impacts on my work :smiley:

A test to detect the list of components from image, sadly the plugin used “EasyOCR” is very slow but work excellent.
I will try to place components in canvas based on the results.

Questions:
How we can create a Polyline with rhino3dm?

-What is the role of Hops - Compute server URLs?

-How we can clear Hops Memory Cache without open Preference everytime?

image

https://mcneel.github.io/rhino3dm/python/api/Polyline.html

I didn’t find how to create Polyline from list of points, i don’t know if that available or not

Have you tried instantiating an empty polyline pline and adding the relevant points one by one with pline.Add(pt)?

The URL is the server address that the Hops component gets its information from.

1 Like

Thanks
Where you get pline.Add(pt)?, Polyline don’t have Add function

It’s probably not documented. :wink:

Polyline derives from a Point3dList which has an Add function
https://mcneel.github.io/rhino3dm/python/api/Point3dList.html#rhino3dm.Point3dList.Add

1 Like

That’s the only location to clear the memory cache. If you don’t want to use the memory cache, then you can specify this on the Hops component itself

Thanks, in rhino3dm documentation isn’t clear.
We must add x,y,z values separated

import rhino3dm as rh

poly = rh.Polyline()

x = [0,1,4]
y = [0,0,2]
z = [0,0,0]

for i in range(3):
    poly.Add(x[i],y[i],z[i])
    poly.ToPolylineCurve()

print (poly)
------------------------------------------
<rhino3dm._rhino3dm.Polyline object at 0x00000269E991AB70>