Streaming Custom GcodeΒΆ
3DIAX has the ability to securely store model data, slice that model data to produce toolpaths for manufacturing devices, and stream the toolpath instructions securely. Users can create a process pipeline using these services or use each service independently. In this tutorial we are going to cover how to use just the secure streaming service by itself.
Let’s assume you have some gcode. This could be generated in any way you like, and you want to stream it to a printer. We will start from scratch and only assume that you have a username and password, and you have gotten yourself authenticated to 3DIAX (Client Authentication)
We need to appoint a printer to stream to. You can get a list of supported printers with this request:
GET https://print.authentise.com/printer/model/
Content-Type: application/json
{
"resources" : [{
"baud_rate" : 250000,
"bed_size" : "285,153,155",
"description" : None,
"driver_name" : "reprap_1.01",
"filament_diameter" : 2.85,
"heated_bed" : False,
"manufacturer" : "Ultimaker",
"name" : "Ultimaker Original",
"nozzle_diameter" : 0.4,
"uri" : "https://print.authentise.com/printer/model/1/",
"uuid" : 1
},{...}]
}
You will get back a list of printer models. I have only shown one here as a representative sample, you will get a long list. Find the model that most closely matches your printer and pull out the URI
value which is how we identify the model. We can use that to create an instance of this printer:
POST https://print.authentise.com/printer/instance/
Content-Type: application/json
{
"name" : "my demo printer",
"printer_model" : "https://print.authentise.com/printer/model/1/",
"baud_rate" : 250000,
"port" : "COM3",
"client" : "https://print.authentise.com/client/abc-123/",
}
Location: https://print.authentise.com/printer/instance/3710/
I have provided a name for the printer, which is just a way for me to identify it. I reference the model which I pulled from the listing above. Now I have to specify the baud rate for the printer (which I pulled from the printer model’s default baud rate). The baud rate may be different from the default if you have modified your printer. The port goes along with the baud rate and will depend on your operating system and installation of the printer. I also specified the client that is connected to the printer. A client is an installation of the Authentise application.
This request responds with a Location
header that identifies the new printer. I can GET
against that location header and get information about the printer and its status:
GET https://print.authentise.com/printer/instance/3710/
Content-Type: application/json
{
"baud_rate" : 250000,
"client" : "https://print.authentise.com/client/abc-123/",
"current_print" : None,
"name" : "my demo printer",
"port" : "COM3",
"printer_model" : "https://print.authentise.com/printer/model/1/",
"status" : "online",
"temperatures" : {
"bed" : {
"current" : 25.47,
"modified" : "2015-12-15T22:31:59.400846",
"target" : None
},
"extruder1" : {
"current" : 19.98,
"modified" : "2015-12-15T22:31:59.405766",
"target" : None
}
},
"uri" : "https://print.authentise.com/printer/instance/3710/"
}
This shows some of the same parameters for my printer that I specified as well as some additional information. For instance, it shows that the printer is not currently printing, that it is online and what the temperatures are. You can poll this endpoint as prints progress to get information about the print.
Next, in order to do a print I need to upload the gcode I want to print. We need to indicate to 3DIAX our intent to upload gcode by creating a gcode resource. It is a simple request:
POST https://quickslice.authentise.com/gcode/
Content-Type: application/json
{
"name" : "My demo gcode"
}
Location: https://quickslice.authentise.com/gcode/xxx-yyy/
X-Upload-Location: https://quickslice.authentise.com/uploads/000-111/
I only need to provide a name for this gcode. In response I get back two headers, one, Location
, which is the URI for this newly created resource. The second, X-Upload-Location
is where I can send the gcode that will become the content for this gcode resource. This request is a bit special and must be made via PUT
and must include the Content-Type
header set to application/octet-stream
:
PUT https://quickslice.authentise.com/uploads/000-111/
Content-Type: application/octet-stream
; perimeters extrusion width = 0.50mm
; infill extrusion width = 0.52mm
; solid infill extrusion width = 0.52mm
; top infill extrusion width = 0.52mm
G21 ; set units to millimeters
M107
M190 S30 ; wait for bed temperature to be reached
M104 S220 ; set temperature
G28 ; home all axes
G1 Z5 F5000 ; lift nozzle
M109 S220 ; wait for temperature to be reached
G90 ; use absolute coordinates
G92 E0
M82 ; use absolute distances for extrusion
G1 F1800.000 E-1.00000
G92 E0
...
The gcode that you upload in this request should not be form-encoded or use any other type of encoding - just send the raw contents of the gcode you wish to stream in the body of the request.
If you GET
against the gcode resource you can see what happens to the gcode as it gets uploaded into 3DIAX:
GET https://quickslice.authentise.com/gcode/xxx-yyy/
Content-Type: application/json
{
"content" : "https://quickslice.authentise.com/uploads/000-111/",
"name" : "My demo gcode",
"status" : "not-uploaded"
}
This shows that the gcode has not yet been uploaded. After we upload the gcode we will see a response body like this:
GET https://quickslice.authentise.com/gcode/xxx-yyy/
Content-Type: application/json
{
"content" : "https://quickslice.authentise.com/uploads/000-111/",
"name" : "My demo gcode",
"status" : "processed"
}
This indicates that the gcode has been injested by 3DIAX and is ready for printing. If the gcode you upload is invalid in some way you will see a status
value of error
and a message indicating what caused the error.
We are now ready to print the gcode. We just have to tell 3DIAX to do so:
POST https://print.authentise.com/print/
Content-Type: application/json
{
"printer" : "https://print.authentise.com/printer/instance/3710/",
"gcode" : "https://quickslice.authentise.com/gcode/xxx-yyy/"
}
Location: https://print.authentise.com/job/2401/
In this request we merely have to specify the printer that we created above and the gcode resource. The parameter is called slicing_job
because normally we expect to have sliced it internally with Authentise. In this case, however, the slicing was done by another tool and merely the gcode uploaded.
With all of this done the print will start as soon as the client controlling the printer is ready. You can watch the status changes by polling the printer that will be handling the print job:
GET https://print.authentise.com/printer/instance/3710/
Content-Type: application/json
{
"baud_rate" : 250000,
"client" : "https://print.authentise.com/client/abc-123/",
"current_print" : {
"job_uri" : "https://print.authentise.com/job/2401/",
"percent_complete" : 0.0,
"remaining" : None,
"status" : "NEW"
},
"name" : "my demo printer",
"port" : "COM3",
"printer_model" : "https://print.authentise.com/printer/model/1/",
"status" : "online",
"temperatures" : {
"bed" : {
"current" : 25.47,
"modified" : "2015-12-15T22:31:59.400846",
"target" : None
},
"extruder1" : {
"current" : 19.98,
"modified" : "2015-12-15T22:31:59.405766",
"target" : None
}
},
"uri" : "https://print.authentise.com/printer/instance/3710/"
}
This is very similar to the request we made before, but now we have a populated value for current_print
. This value will change as the print progresses. At this point my print hasn’t started yet. I will show the overall progression below, but leave out the parts that stay the same for my print job:
GET https://print.authentise.com/printer/instance/3710/
Content-Type: application/json
{
...
"current_print" : {
'job_uri': 'https://print.authentise.com/job/2401/',
'percent_complete': 5.58,
'remaining': None,
'status': 'WARMING_UP'
},
...
}
Now the printer is warming:
GET https://print.authentise.com/printer/instance/3710/
Content-Type: application/json
{
...
"current_print" : {
'job_uri': 'https://print.authentise.com/job/2401/',
'percent_complete': 15.87,
'remaining': None,
'status': 'PRINTING'
},
"temperatures" : {
"bed" : {
"current" : 60.33,
"modified" : "2015-12-15T22:31:59.400846",
"target" : 60
},
"extruder1" : {
"current" : 219.98,
"modified" : "2015-12-15T22:31:59.405766",
"target" : 220
}
},
}
During the course of the print the temperature will fluctuate and the percent complete will steadily increase. Eventually the status will change to COMPLETE
as the print completes.
If you need help or additional information you can reach us via info@authentise.com.