Connecting GH to 3D printer with http request


I am trying to connect grasshopper to a 3D printer running klipper/moonraker

I’ve read “C# call REST client with x-api-key within grasshopper” and used some code from there for a http get request and it works. The 3d Printer / Moonraker returns a json object which is parsed with jswan. In this way the current position of the extruder can be retrieved in GH as a point…

Unfortunately the whole definition is quite messy and I have little understanding of the c# script; that’s also why the response is stored in a global var. in python script

I would like to combine all this functionality ( sending request, storing the response, deserializing json object) in one c# component but have no starting point how to get there…

Is there already something out there that can do this? I image post/get request are quite common / as is json… or any other tips how to do this -

Thanks! (18.5 KB)

1 Like

I would 1. re-write the python component with c# and 2. Create two classes one HTTP request and the other store data i.e.

Hi all,

I switched to python and came up with this:


It uses urllib2 to send the request by navigating to the url and de-serializes the response with the builtin json library. In my use case this works fine -ymmv. I also did a version which doesn’t wait for the answer by using threads:


One thing to keep in mind is that you have to replace spaces with %20 and newline with %0A for more complex commands. (6.9 KB)

If someone is interested in the control interface for the printer contact me via pm.

1 Like