Rhino compute send .3dm file with .ghx

Can I send the 3dm file to rhino.compute?

Yes. You could send a base64 string representation of the 3dm file to a string input in the gh definition. You could also of course, send the objects inside the 3dm file. What are you trying to do?

How can I save in .3dm the view that is shown when opening the .ghx file in metres, but with rhino.compute?

poly.ghx (275.3 KB)
qgis.zip (40.2 KB)

import compute_rhino3d.Brep
import rhino3dm
import requests
import base64
import json

compute_rhino3d.Util.authToken = "token"
compute_rhino3d.Util.url = "http://localhost:8081/"
post_url = compute_rhino3d.Util.url + "grasshopper"

gh_data = open("poly.ghx", mode="r", encoding="utf-8-sig").read()
data_bytes = gh_data.encode("utf-8")
encoded = base64.b64encode(data_bytes)
decoded = encoded.decode("utf-8")
response = requests.post(post_url, json={"algo": decoded, "pointer": None, "values": []})
res = response.content.decode("utf-8")
res = json.loads(res)

It seems you want to return the resulting Rhino geometry as a Rhino “file” from the gh definition. These two examples include a definition that returns a Rhino Document with objects:

1 Like