@hops.component( "/pointat", name="PointAt", nickname="PtAt", description="Get point along curve", category="Curve", subcategory="Analysis", 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) @hops.component( "/srf4pt", name="4Point Surface", nickname="Srf4Pt", description="Create ruled surface from four points", category="Surface", subcategory="Freeform",
for e, etype in zip(edges, edges_types): G.add_edge(p3d_to_tuple(e.From), p3d_to_tuple(e.To), type=etype, length=e.Length) return G def extract_types(G): return list(nx.get_edge_attributes(G, 'type').values()) @hops.component( "/lines_14", name="Lines", inputs=[ hs.HopsCurve("Edges", "E", access=hs.HopsParamAccess.LIST), hs.HopsString("EdgesTypes", "ET", access=hs.HopsParamAccess.LIST), hs.HopsPoint("AgentsCoordinates", "AC", access=hs.HopsParamAccess.LIST), hs.HopsString("AgentsTypes", "AT", access=hs.HopsParamAccess.LIST), hs.HopsNumber("Updater", "u"), ], outputs=[ hs.HopsString("NewTypes", "NT", access=hs.HopsParamAccess.LIST) ] ) def lines(edges: [Curve], edges_types: [str], agents_coordinates: [Point3d], agents_types: [str], _): G = init_graph(edges, edges_types) EdgeType.set_weight(G) city_graph = CityGraph(G, geo_graph=False) print_edges(G) print_nodes(G)
#MESH WALKER COMPONENT --------------------- #global variables for meshwalker component walkerGraph = None @hops.component( "/meshwalker", name = "meshwalker", inputs=[ hs.HopsBoolean("reset","R","reset button"), hs.HopsMesh("Input Mesh", "M", "Mesh"), hs.HopsInteger("face Index 1","f1","Face index one"), hs.HopsInteger("face Index 2","f2","Face index two") ], outputs=[ hs.HopsPoint("list of points","P","shortest path points", hs.HopsParamAccess.LIST), hs.HopsInteger("list of faces indexes","F","shortest path face indexes", hs.HopsParamAccess.LIST) ] ) def meshwalker(reset, mesh, f1, f2): global walkerGraph #do something with this mesh if reset: walkerGraph = mp.graphFromMesh(mesh) #convert the mesh to a nx graph else: #use the graph to find the shortest path between two faces SP = mp.dijkstraPath(walkerGraph, f1, f2) pts = SP[0] faceInd = SP[1]
# flask app can be used for other stuff drectly @app.route("/help") def help(): return "Welcome to Grashopper Hops for CPython!" #-- Point At component --# @hops.component( "/pointat", name="PointAt", description="Get a point along a curve", 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 parameter t") ] ) def pointat(curve: rh.Curve, t: float=0): pt = curve.PointAt(t) return pt #-- Profile Levels component --# @hops.component( "/plevels", name="ProfileLevels", description="Creates a series of levels from a profile", inputs=[ hs.HopsCurve("Curve", "C", "Curve to replicate"), hs.HopsNumber("Dist", "D", "Distance between levels"),
from PIL import Image from matplotlib import pyplot as plt os.environ['TF_CPP_MIN_LOG_LEVEL'] = '3' app = Flask(__name__) hops = hs.Hops(app) @hops.component( "/runml", name="runml", description="Run Machine Learning prediction", icon="examples/pointat.png", inputs=[ hs.HopsBoolean("B","BO","Boolean"), ], outputs=[ hs.HopsPoint("P", "P", "Point on curve at t"), ] ) def run_ml(): if hs.HopsBoolean == True: exec('runPython.py') print("Model OK") if __name__ == "__main__": app.run()
import Rhino.Geometry as rg hops = hs.Hops(app=rhinoinside) import networkx as nx import MeshPaths as mp @hops.component( "/MeshPathWalker", name="MeshPathWalker", description= " Make a networkx graph with mesh vertices as nodes and mesh edges as edges ", inputs=[ hs.HopsMesh("Mesh", "M", "Mesh to make networkx graph for"), hs.HopsString("WeightMode ", "W", "Weight Mode"), hs.HopsString("GraphType", "T", "Mesh Graph Type"), hs.HopsLine("SLine", "L", "Line to process"), hs.HopsString("mode", "m", "Shortest Path Mode") ], outputs=[ hs.HopsPoint("ShortestPath", "SP", "Shortest Path", hs.HopsParamAccess.LIST), hs.HopsString("FacesIndex", "I", "Faces indexes", hs.HopsParamAccess.LIST) ]) def MeshPathWalker(mesh, weightMode, GraphType, SLine, mode): return mp.meshwalker(mesh, weightMode, GraphType, SLine, mode) if __name__ == "__main__": hops.start()
@hops.component( "/pointat", name="PointAt", nickname="PtAt", description="Get point along curve", category="Curve", subcategory="Analysis", 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) @hops.component( "/srf4pt", name="4Point Surface", nickname="Srf4Pt", description="Create ruled surface from four points", category="Surface", subcategory="Freeform", inputs=[
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()