Task 4 – Download STL file
In order to download the translated STL file, you must wait until the translation job is complete. There are two ways to check if the translation job is done:
- Periodically download and check the manifest.
- Set up a webhook to notify you when the job is done.
For this walkthrough you download the manifest and check the status of the job. For more information on webhooks, see the documentation on Model Derivative webhook events
By the end of this task you will be able to:
- Get the URN of a translated file (Get the URN of a derivative).
- Download a translated file (Download a derivative).
You will use the following operations in this task:
Step 1 - Check the status job
In this step you check if the translation job is done (by verifying that progress
is complete
). You proceed to the next step only if the translation job is done.
curl -X GET \
-v 'https://developer.api.autodesk.com/modelderivative/v2/designdata/<URL_SAFE_URN_OF_SOURCE_FILE>/manifest' \
-H 'Authorization: Bearer <YOUR_ACCESS_TOKEN>'
When the translation job completes successfully, you see a response similar to:
Response
{
"urn":"dXJuOmFkc2sub2JqZWN0czpvcy5vYmplY3Q6c2pzc18wMi9UdW5lci56aXA",
"derivatives":[
{
"children":[
{
"urn":"urn:adsk.viewing:fs.file:dXJuOmFkc2sub2JqZWN0czpvcy5vYmplY3Q6c2pzc18wMi9UdW5lci56aXA/output/9ab9410a-38fc-4105-a966-cc5c264e0d52/Tuner.stl",
"role":"STL",
"exportFileStructure":"single",
"mime":"application/octet-stream",
"exportColor":true,
"format":"binary",
"guid":"db55b0eb-649c-415e-b9aa-237744eb8e6f",
"type":"resource",
"status":"success"
}
],
"progress":"complete",
"outputType":"stl",
"status":"success"
}
],
"hasThumbnail":"false",
"progress":"complete",
"type":"manifest",
"region":"US",
"version":"1.0",
"status":"success"
}
Notice that the translation job has produced two derivatives; an STL file and an MTL file. For this walkthrough we are only interested in the STL file. The MTL file is an auxiliary file containing material definitions, which can be accessed by the STL file. If the source file contained textures, you would have seen a third child in the list of derivatives.
Note down the value of the urn
of the STL file. You will use this value when you download the STL file. For the next step we will refer to it as <URN_OF_STL_FILE>.
Step 3 - Download the STL file
Use the download URL and the signed cookies to download STL file that was generated in task 3. The signed cookies protect access to the STL file while letting you download it securely.
- Send a request to download the OBJ file.
Request
curl -X GET \
'<SIGNED_DOWNLOAD_URL>'\
-H 'Cookie: <FIRST_SIGNED_COOKIE>;<SECOND_SIGNED_COOKIE>;<THIRD_SIGNED_COOKIE>'
Response
<CONTENT_OF_STL_FILE>
Step 4 - Save the STL file
- Copy the chunked content body to a text file and save it as Tuner.stl
Notes
To display the saved file: 1. If you are using an Apple Macintosh, right-click Tuner.stl in Finder and select Quick View from the menu. 2. If you are using Windows, right-click Tuner.stl in Windows Explorer and select Open with > 3D Viewer from the menu.