Tutorial

Packing service is a very interesting and straightforward product. In this tutorial I’m going to show you how to get a layout from given models. We’ll start with a few models that I’ve uploaded:

../_images/models_layout.png

For my tutorial I will be working on these models. They will be called ‘40mmcube’, ‘20mmcube’ respectively. I have uploaded this model and gotten back the URI. You can learn more about how to upload models to 3Diax in 3DIAX API Reference. The URI is as follows:

model URIs
Model Model URI
40mmcube https://models.dev-auth.com/model/5270d0ca-2018-42f5-a20d-e29a580135c9/
20mmcube https://models.dev-auth.com/model/e0692173-863c-40ab-b798-c93911085203/

This is important because Packing service relies on model URIs to do its work. Packing module doesn’t expect you to move model data around yourself - that would be extremely inconvenient since they may be many hundreds of megabytes in size. Instead you use URIs as a pointer to a model and keep the data very light and fast.

Here, I will try to pack one ‘40mmcube’ and 2 ‘20mmcube’ models in a build plate of 300x400 mm. Lets say, I wish to have a good 5mm spacing between the packed models. And we have our models ready with the model URIs.

Now we are ready to find a good layout for the models we have in hand. The request would be like this:

POST https://quoting.authentise.com/layout/

Content-Type: application/json

{
    'build'           : {
        'type'        : 'rectangle',
        'x'           : 300.0,
        'y'           : 400.0,
        'z'           : 200.0,
    },
    'callback'     : {
        'method'   : "POST",
        'url'      : "http://localhost/callback",
    },
    'models'          : [
        'https://models.dev-auth.com/model/5270d0ca-2018-42f5-a20d-e29a580135c9/',
        'https://models.dev-auth.com/model/e0692173-863c-40ab-b798-c93911085203/',
        'https://models.dev-auth.com/model/e0692173-863c-40ab-b798-c93911085203/',
    ],
    'spacing'         : 5.0,
}

The response from the POST request for the 40mmcube and 2 20mmcube will have response header with 204 status once the request is successful. The user should have set the callback URL in order to obtain the layout. You can checkout our callback service here callback-service. Once the user gets a success on the POST resource, he can do a GET on the callback URL to get the layout for the models.

GET http://localhost/callback

{'resources': [{
    'callback'     : {
        'method'   : "POST",
        'url'      : "http://localhost/callback",
    },
    'build': {
        'z': 200.0,
        'x': 300.0,
        'y': 400.0,
        'type': 'rectangle'
    }
    'error': None,
    'fill_percentage': 4.64,
    'models': [
        'https://models.dev-auth.com/model/5270d0ca-2018-42f5-a20d-e29a580135c9/',
        'https://models.dev-auth.com/model/e0692173-863c-40ab-b798-c93911085203/',
        'https://models.dev-auth.com/model/e0692173-863c-40ab-b798-c93911085203/'
    ],
    'positions': [{
        'location': {
            'z': None,
            'x': 102.0,
            'y': 127.5
        },
        'size': {
            'z': 40.0,
            'x': 40.0,
            'y': 40.0
        },
        'model': 'https://models.dev-auth.com/model/5270d0ca-2018-42f5-a20d-e29a580135c9/'},
        {
        'location': {
            'z': None,
            'x': 147.5,
            'y': 127.5
        },
        'size': {
            'z': 10.0,
            'x': 20.0,
            'y': 20.0
        },
        'model': 'https://models.dev-auth.com/model/e0692173-863c-40ab-b798-c93911085203/'},
        {
        'location': {
            'z': None,
            'x': 172.5,
            'y': 127.5
        },
        'size': {
            'z': 10.0,
            'x': 20.0,
            'y': 20.0
        },
        'model': 'https://models.dev-auth.com/model/e0692173-863c-40ab-b798-c93911085203/'}],
    'status': 'complete',
    'spacing': 5.0,

}]}

The response contains the position of each model along with the model URI and its location in (x, y, z) coordinates in the build plate. It also tells the percentage of build plate filled which helps in deciding whether to add new models or remove existing models. This service helps in creating a single layout for given set of models which helps in optimizing time and space for the print process.

You can find detailed information on how to use the Packing Service in Reference.