Hey,
Here’s another question about Cpython Hops
Will it ever support custom types?
The first Hops component cannot use the repr function so pass to Grasshopper.
And even if it did, I guess the Hops input type of the second component would need something else than the hs.HopsString type.
–
Here’s the basic Hops version
from flask import Flask
import ghhops_server as hs
app = Flask(__name__)
hops: hs.HopsFlask = hs.Hops(app)
class HelloWorld:
def __init__(self, count):
self.message = "Hello World"
self.count = count
def __repr__(self):
return "repr lives matter"
@hops.component(
"/class",
name = "Class repr test",
nickname = "repr test",
description = "Test the repr of a class",
inputs = [
hs.HopsInteger("Count", "C", "Count of hello worlds")
],
outputs = [
hs.HopsString("Repr", "R", "Repr of the class")
]
)
def test_repr(counter):
return HelloWorld(counter)
@hops.component(
"/message",
name = "Message",
nickname = "Message",
description = "Prints a message multiple times",
inputs = [
hs.HopsString("Repr", "R", "Would read the object, not the repr string")
],
outputs = [
hs.HopsString("Messages", "M", "Messages printed a number of times")
]
)
def messages(my_object):
return [my_object.message] * int(my_object.count)
if __name__ == "__main__":
app.run(debug=False)
@stevebaer, let me know if I should tag someone else instead