Hops

How to use hops

  • Install hops in windows in package manager.

  • Create hops definition similar to cluster, using inputs and outputs (RH_OUT:Slabs). Settings name, prompt, enable/disable, at least, at most, minimum and maximum, presets.

  • Set definition (grasshopper definition on your computer, on a remote computer or a REST endpoint).

Hops settings

  • Application settings: server URL, API key, max concurrent request (limit number of active requesting asynchronous situations), clear hops memory cache, child process count (may want to set this to the number of cores available; used to limit the number of request for additional parallel processes).

  • Component setting: parallel computing, path, asyncronous (the UI not be blocked while waiting for a remote process to solve and the definition will be updated when the solve is completed), cache in memory, cache on server.

  • Port 5000 is not a commonly used port for any particular service or protocol. It is considered a "dynamic" or "private" port, which means it can be used by an application or service for any purpose. In general, port numbers in the range from 0 to 1023 are reserved for use by specific protocols and services, while port numbers in the range from 1024 to 49151 are designated as "dynamic" or "private" ports that can be used by any application or service. Port numbers in the range from 49152 to 65535 are reserved for use by specific protocols and services, but are not officially assigned and can be used for custom or experimental purposes.

Remote machine configuration

[[Deployment to production servers]] API calls.

Calling a CPython server

  • Libraries: Numpy and SciPy or TensorFlow.

  • Create re-usable function and parallel procesing.

  • Support real debugging modes including breakpoints (vscode). Support other apps and services that support a Python API (built-in default HTTP server to serve the function as gh components).

  • Detects when inputs and outputs have change on server and will rebuild itself.

  • Requirements: rhino 7+, cyython 3.8+.

from flask import Flask
import ghhops_server as hs

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

@hops.component(
    "/pointat", name="PointAt", description="Get point along curve", icon="examples/pointat.png",
    inputs=[
        hs.HopsCurve("Curve", "C", "Curve to evaluate"),
        hs.HopsNumber("t", "t", "Parameter on Curve to evaluate"),
    ],
    outputs=[
        hs.HopsPoint("P", "P", "Point on curve at t")
    ]
)

def pointat(curve, t):
    return curve.PointAt(t)

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

Frequent question

@hops.component( 
	"fruitsalad", name="Fruit salad", nickname="FS", description="A salad of fruits", 
	inputs=[ hs.HopsString("Fruits", "F", "List of fruits", hs.HopsParamAccess.LIST) ], 
	outputs=[ hs.HopsString("FruitSalad", "FS", "A delicious fruit salad") ] ) 

def create_fruit_salad(my_fruits): 
	pealed_fruits = peel_fruits(my_fruits) 
	cutted_fruits = cut_fruits(pealed_fruits) 
	return make_salad(cutted_fruits)

Useful libraries

Create CPython components using Hops in Grasshopper - Grasshopper / Hops - McNeel Forum compute.rhino3d/src/ghhops-server-py at master · mcneel/compute.rhino3d (github.com) Rhino.Inside.QGIS? - Rhino.Inside - McNeel Forum Hops Component with Grasshopper (rhino3d.com) Rhino - The Hops Component (rhino3d.com)

Última actualización

¿Te fue útil?