How to pass mesh to Hops

,

Hi there, I can’t seem to pass a mesh to my hops component, any help is appreciated.

from flask import Flask
import ghhops_server as hs
import rhino3dm as r3

#register hops app as middleware
app = Flask(__name__)
hops = hs.Hops(app)

@hops.component(
    "/meshInOut",
    name="meshInOut",
    description="randomly shift mesh vertices",
    inputs=[
        hs.HopsMesh("MeshIn", "M_i", "Mesh to be shifted"),
        hs.HopsNumber("Shift", "s", "distance of shift", default=2.0),
    ],
    outputs = [
        hs.HopsMesh("MeshOut", "M_o", "Shifted Mesh"),
    ],
)
def meshInOut(msh: r3.Mesh, s):
    if type(msh) is None:
        print('what the fuck')
    print((msh))
    for v in msh.Vertices:
        v += np.random.random(3)*s
    msh_out = msh
    return msh_out

if __name__== "__main__":
    app.run()

messhift.gh (7.3 KB)

Sorry - I was a bit frustrated. I can’t seem to find any resources that show how to pass a mesh to hops, perhaps it’s just a bug on my end.

Never mind - I got it working in Rhino 7 with hops 0.14.0.

That’s understandable. As far as I can tell the support here for Hops related stuff is not really great. In the advent of better Python 3 support in Rhino 8, my guess is that the project is less of a priority than it previously was and might be rendered superfluous in the future. This is speculative though!

Congrats on making it work.

What version were you using previously?

I was on the WIP 8.0.22361.13136, 2022-12-27 and Hops v0.15.4. I tried with Hops v.0.14.0 and it still is unable to collect the mesh.

Ah, this is a Rhino 8 thing at the moment. We are passing meshes from Hops to the CPython server in a Rhino 8 format and the CPython server only currently knows how to deal with Rhino7 and below formats. We’re actively getting the libraries that the CPython server updated so the server will work with Rhino 8 format.

1 Like