forked from jomiguelcarv/2024-Macad-Speckle-Compute
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfetch.py
41 lines (34 loc) · 1.17 KB
/
fetch.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#py 3.7.7
import compute_rhino3d
import compute_rhino3d.Util
import base64
def send_to_compute():
#Credentials
compute_rhino3d.Util.url = "http://3.78.144.62/"
compute_rhino3d.Util.apiKey = "SpeckleCompute02"
# Change the stream ID to the one you want to send to
send_to_compute_stream = "https://macad.speckle.xyz/streams/b91897b29e"
# Change the path to the GH definition you want to send
gh_definition = "example.ghx"
gh_data = open(gh_definition, mode="r", encoding="utf-8-sig").read()
data_bytes = gh_data.encode("utf-8")
encoded = base64.b64encode(data_bytes)
decoded = encoded.decode("utf-8")
json_data={
"algo": decoded,
"pointer": None,
"values": [
{
"ParamName": "RH_IN:Link",
"InnerTree": {
"{ 0; }": [
{
"type": "String",
"data": send_to_compute_stream
}
]
}
},
]
}
response = compute_rhino3d.Util.ComputeFetch("grasshopper", json_data)