trouble with api not exporting GLTF model

ben_kepner
ben_kepner Member Posts: 5 ✭
I am trying to make a tool for displaying and configuring a model on a web page. I got it working with exporting STL models, but the good javascript libraries for viewing models want GLTF. When I try to use the api endpoint for exporting it a GLTF, it appears to just return not enough data. The response code is '200 OK'
request URL: 
https://cad.onshape.com/api/partstudios/d/6844173a888ae9c148ad6b67/v/57d8fe202591e452ce7fdae4/e/332466e1b8aefa108b60a691/gltf?configuration=add_dividing_walls%3Dtrue%3Badd_living_hinge%3Dfalse%3Badd_tape_slot%3Dfalse%3Badd_window%3Dtrue%3Bbox_depth%3D0.81%3Bbox_height%3D5%3Bbox_width%3D8%3Bdivider_count%3D2&outputSeparateFaceNodes=False&outputFaceAppearances=False

request headers:
{<br>'User-Agent': 'Onshape Python Sample App', <br>'Accept-Encoding': 'gzip, deflate', <br>'accept': 'model/gltf+json;charset=UTF-8;qs=0.08', <br>'Connection': 'keep-alive', <br>'Content-Type': 'application/json', <br>'Date': 'Wed, 26 Jun 2024 21:39:58 GMT', 'On-Nonce': '5UzGLnLZE6SoHJb1AIuXt6fjU', <br>'Authorization': 'On redacted'<br>}

The entire body of the response:
{<br>  "extensions": {<br>    "PTC_onshape_metadata": {<br>      "documentId": "6844173a888ae9c148ad6b67",<br>      "elementId": "332466e1b8aefa108b60a691"<br>    }<br>  },<br>  "extensionsUsed": [<br>    "PTC_onshape_metadata"<br>  ],<br>  "asset": {<br>    "version": "2.0"<br>  },<br>  "scene": 0,<br>  "scenes": [<br>    {}<br>  ]<br>}

Best Answers

  • ben_kepner
    ben_kepner Member Posts: 5 ✭
    Answer ✓
    I am getting the same result from glassworks.

    cloudflare threw a fit when I tried to past the results of the glassworks request into the post, so I made a pastebin. https://pastebin.com/xQWwxDeJ


  • Paul_J_Premakumar
    Paul_J_Premakumar Member, Onshape Employees Posts: 238 image
    edited June 2024 Answer ✓

    Hi Ben, Can you include the units in the configuration string i.e. 

    box_depth%3D2+cm
    for example, this works for me

    https://cad.onshape.com/api/v6/partstudios/d/6844173a888ae9c148ad6b67/v/57d8fe202591e452ce7fdae4/e/332466e1b8aefa108b60a691/gltf?configuration=add_dividing_walls%3Dfalse%3Badd_living_hinge%3Dtrue%3Badd_tape_slot%3Dfalse%3Badd_window%3Dtrue%3Bbox_depth%3D2+cm%3Bbox_height%3D7+cm%3Bbox_width%3D8+cm%3Bdivider_count%3D1&outputSeparateFaceNodes=False&outputFaceAppearances=False

    I suspect the configurations without the units is resulting in invalid geometry and hence you are getting no output.

Answers

  • Paul_J_Premakumar
    Paul_J_Premakumar Member, Onshape Employees Posts: 238 image
    I was able to download the content using glassworks. As a test can you try downloading this with glassworks ? https://cad.onshape.com/glassworks/explorer#/PartStudio/exportPartStudioGltf . If that works, you may need to check the calls being made via the app.
  • ben_kepner
    ben_kepner Member Posts: 5 ✭
    Answer ✓
    I am getting the same result from glassworks.

    cloudflare threw a fit when I tried to past the results of the glassworks request into the post, so I made a pastebin. https://pastebin.com/xQWwxDeJ


  • Paul_J_Premakumar
    Paul_J_Premakumar Member, Onshape Employees Posts: 238 image
    edited June 2024 Answer ✓

    Hi Ben, Can you include the units in the configuration string i.e. 

    box_depth%3D2+cm
    for example, this works for me

    https://cad.onshape.com/api/v6/partstudios/d/6844173a888ae9c148ad6b67/v/57d8fe202591e452ce7fdae4/e/332466e1b8aefa108b60a691/gltf?configuration=add_dividing_walls%3Dfalse%3Badd_living_hinge%3Dtrue%3Badd_tape_slot%3Dfalse%3Badd_window%3Dtrue%3Bbox_depth%3D2+cm%3Bbox_height%3D7+cm%3Bbox_width%3D8+cm%3Bdivider_count%3D1&outputSeparateFaceNodes=False&outputFaceAppearances=False

    I suspect the configurations without the units is resulting in invalid geometry and hence you are getting no output.

  • ben_kepner
    ben_kepner Member Posts: 5 ✭
    adding units to the request worked. I wonder why it worked without for the stl endpoint?