Closed jmandel1027 closed 4 years ago
Linked with COMPUTE-102
You can interact with the server via curl but it’s much less user friendly than using the client libraries, particularly when sending/receiving geometry. What is it that you want to do?
hey @pearswj sorry for the blank issue, accidentally hit enter while writing it.
the example i described above is very simplistic but my ultimate goal is to programmatically reconstruct a 3D model from a 2D cad drawing of rebar cages using the rhino api. probably by setting the the cad cross section, defining a parametric curve for the "stirrups" and "long bars" and then lofting across the curves.
I have a back end in go that is communicating with an assembly line of ABB robot arms. and we need a way to pick reference points for assembly and reconstructing the work element as a 3d model from 2d drawings and assembly schedules seems the best way to do so. we have the bend lists, for a machine to transform a long tube of rebar into a curved form and cross sections to do so and the rhino compute service is a really exciting opportunity to do this procedure in a generative fashion
I'd really like to keep the functionality in go, maybe i can retain the geometry state with in the server context?
obviously there's going to be quite a bit of logic i need to write to determine the shapes of the 2D forms, draw the curves and then set reference points from that to start the lofts. but understand that i might either need to implement a go equivalent of the client interface or just write a lambda in python to do the procedures i need.
also thanks for getting back to me so quickly! and have a good thanks giving! :)
Creating a client library in go is probably a huge undertaking as there aren't any tools that I know of for directly wrapping C++ code for use in go. We do have client libraries in python, .NET, and web assembly in case those are of any help to you.
Happy holidays!
Mmm gotcha, there is actually a utility that's part of the Go language designed to do just that, it's called cgo
. It allows the go compiler to operate with C/C++ code. While Go doesn't have classes, we can achieve the same effect with interfaces.
This is a succinct example: https://github.com/burke/howto-go-with-cpp
https://stackoverflow.com/questions/1713214/how-to-use-c-in-go
I found this one to be the most practical example: https://github.com/draffensperger/go-interlang/tree/master/c_to_go/static_go_lib
This is also an nice long form explanation of the process: https://medium.com/mysterium-network/golang-c-interoperability-caf0ba9f7bf3
Thank you both for taking the time to address my Q's! This project is super interesting and opens up a lot of exciting possibilities for my company. In the short term it looks like either the python or web assembly module's make the most sense.
If there's more interest around a Go Client library feel free to reach out! Happy to help in that initiative as best I can.
I’m familiar with cgo which as I understand is the only current framework for interop. If that is the case, then this is a huge undertaking. This process is essentially what we do for our .NET client library and it is a ton of work.
If you're feeling brave (and I wouldn't recommend this) you can achieve something similar to the example you gave in your first post using only curl. Note that our implementation of the server is entirely stateless (so no "scene") and that you also need to convert the Circle
to a NurbsCurve
before you can extrude it. Also, all of this functionality is in opennurbs; if you were to use Python or JavaScript you could eliminate the calls to the server!
$ curl --request POST \
--url 'https://compute.rhino3d.com/rhino/geometry/circle/new' \
--header 'authorization: bearer RHINO_ACCOUNTS_TOKEN' \
--header 'content-type: application/json' \
--data '[{"X":1.0,"Y":2.0,"Z":3.0}, 12]'
{
"Radius": 12.0,
"Plane": {
"Origin": {
"X": 1.0,
"Y": 2.0,
"Z": 3.0
},
"XAxis": {
"X": 1.0,
"Y": 0.0,
"Z": 0.0
},
"YAxis": {
"X": 0.0,
"Y": 1.0,
"Z": 0.0
},
"ZAxis": {
"X": 0.0,
"Y": 0.0,
"Z": 1.0
},
"Normal": {
"X": 0.0,
"Y": 0.0,
"Z": 1.0
}
},
"Center": {
"X": 1.0,
"Y": 2.0,
"Z": 3.0
},
"Normal": {
"X": 0.0,
"Y": 0.0,
"Z": 1.0
}
}
$ curl --request POST \
--url 'https://compute.rhino3d.com/rhino/geometry/circle/tonurbscurve' \
--header 'authorization: bearer RHINO_ACCOUNTS_TOKEN' \
--header 'content-type: application/json' \
--data '[
{
"Radius": 12.0,
"Plane": {
"Origin": {
"X": 1.0,
"Y": 2.0,
"Z": 3.0
},
"XAxis": {
"X": 1.0,
"Y": 0.0,
"Z": 0.0
},
"YAxis": {
"X": 0.0,
"Y": 1.0,
"Z": 0.0
},
"ZAxis": {
"X": 0.0,
"Y": 0.0,
"Z": 1.0
},
"Normal": {
"X": 0.0,
"Y": 0.0,
"Z": 1.0
}
},
"Center": {
"X": 1.0,
"Y": 2.0,
"Z": 3.0
},
"Normal": {
"X": 0.0,
"Y": 0.0,
"Z": 1.0
}
}
]'
{
"version": 10000,
"archive3dm": 60,
"opennurbs": -1912573411,
"data": "+n8CAP4BAAAAAAAA+/8CABQAAAAAAAAAGRGvXlEL1BG//gAQgwEi8EoaeRf8/wIAxgEAAAAAAAARAwAAAAEAAAADAAAACQAAAAAAAAAAAAAAAAAAAAAA8D8AAAAAAAAAAAAAAAAAAAAAAAAAAAAA8L8AAAAAAAAAAAAAAAAAAAAACgAAAAAAAAAAAAAAAAAAAAAAAAAYLURU+yH5PxgtRFT7Ifk/GC1EVPshCUAYLURU+yEJQNIhM3982RJA0iEzf3zZEkAYLURU+yEZQBgtRFT7IRlACQAAAAAAAAAAACpAAAAAAAAAAEAAAAAAAAAIQAAAAAAAAPA/lmBHs4BiIkBSVK+ZiswjQNls38x2+ABAzDt/Zp6g5j8AAAAAAADwPwAAAAAAACxAAAAAAAAACEAAAAAAAADwPzjy7szZHB/AUlSvmYrMI0DZbN/MdvgAQMw7f2aeoOY/AAAAAAAAJsAAAAAAAAAAQAAAAAAAAAhAAAAAAAAA8D848u7M2RwfwL8KHwDGSBzA2WzfzHb4AEDMO39mnqDmPwAAAAAAAPA/AAAAAAAAJMAAAAAAAAAIQAAAAAAAAPA/lmBHs4BiIkC/Ch8AxkgcwNls38x2+ABAzDt/Zp6g5j8AAAAAAAAqQAAAAAAAAABAAAAAAAAACEAAAAAAAADwPwCFva5K/38CgAAAAAAAAAAA"
}
$ curl --request POST \
--url 'https://compute.rhino3d.com/rhino/geometry/extrusion/create-curve_double_bool' \
--header 'authorization: bearer RHINO_ACCOUNTS_TOKEN' \
--header 'content-type: application/json' \
--data '[
{
"version": 10000,
"archive3dm": 60,
"opennurbs": -1912573411,
"data": "+n8CAP4BAAAAAAAA+/8CABQAAAAAAAAAGRGvXlEL1BG//gAQgwEi8EoaeRf8/wIAxgEAAAAAAAARAwAAAAEAAAADAAAACQAAAAAAAAAAAAAAAAAAAAAA8D8AAAAAAAAAAAAAAAAAAAAAAAAAAAAA8L8AAAAAAAAAAAAAAAAAAAAACgAAAAAAAAAAAAAAAAAAAAAAAAAYLURU+yH5PxgtRFT7Ifk/GC1EVPshCUAYLURU+yEJQNIhM3982RJA0iEzf3zZEk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/Zp6g5j8AAAAAAAAowAAAAAAAAChAAAAAAAAA8D/ZbN/MdvggwAAAAAAAAAAAzDt/Zp6g5j8AAAAAAAAAAAAAAAAAAAAAAAAAAAAA8D8AHukHU/9/AoAAAAAAAAAAAAAAAAAAACpAAAAAAAAAAEAAAAAAAAAIQAAAAAAAACpAAAAAAAAAAEAAAAAAAAA3QAAAAAAAAAAAAAAAAAAA8D/////////vvwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAANEAAAQAAAAEBAIAAQA0AAAAAAAAAAQAAAAAAAAAA7QBy8XuNnwUAAAAA/38CgAAAAAAAAAAA"
}
Thanks @pearswj Interesting! This gives me a lot further insight into the mechanics of interacting with the service. Fwiw I'm proceeding with writing this project in python.
Thanks again for humoring me and for the informative answers!
-J
Closed via COMPUTE-102
This is a really exciting project!
I have a backend in Go that i would like to use controller to interface with the compute service. I'd like to stick with go but it's not truly a dealbreaker for me. To map out the functionality i'd need to write in Go i like to ping endpoints with cURL. I'm curious to learn how i can chain operations together with individual rest operations agains the compute service.
This is a simplistic example but would go a long way in helping me understand some of the server mechanics for use with cURL:
i did see the expansive list of endpoints exposed by the api but i'm still a bit fuzzy on the operations required to chain things together, from call to call.
again my end goal is to write a client to the compute api in Go with the intention of open sourcing it as a standalone package, but wanted to get a lay of the land with cURL.
additionally are there any resources for the compute.frontend service? i didn't seem to be able to find any
thanks again, this is a super super super exciting project.
-J