Exporting Assemblies to Collada via the REST API?
Doug_Stephen
Member Posts: 7 PRO
As the title says, I'm curious if this is possible. I've been playing with the REST API Explorer for a few days now, and I can't seem to find what I'm looking for but as the documentation is a little sparse I'm just not sure if it's something I've missed.
Our use-case is that we are using OnShape to develop models for robots, which would then have their physical properties and graphical meshes exported out so that we can use these models in dynamics simulations like Gazebo or our own in-house simulation software.
I've found where it's possible to export .STL files from Part Studios, but this falls a little short. STL loses some of the material properties that we care about and Part Studios are too granular; some of our meshes are assemblies that don't necessarily have articulation but are built up from several separate parts.
Is this something that's possible or at the least on the road map?
Thanks for taking a look at this!
Our use-case is that we are using OnShape to develop models for robots, which would then have their physical properties and graphical meshes exported out so that we can use these models in dynamics simulations like Gazebo or our own in-house simulation software.
I've found where it's possible to export .STL files from Part Studios, but this falls a little short. STL loses some of the material properties that we care about and Part Studios are too granular; some of our meshes are assemblies that don't necessarily have articulation but are built up from several separate parts.
Is this something that's possible or at the least on the road map?
Thanks for taking a look at this!
Tagged:
1
Best Answer
-
Hi @Doug_Stephen,
Any formats that can be exported through the UI should also be exportable through the API. See below for what you should be looking for in the API Explorer.
Assemblies/PartStudios -> Get Translation Formats
Will return the list of formats that we support for assemblies and part studios. Note that although this request takes an elementId, at this point all elements of the same type will have the same export formats available.
Assemblies -> Create Assembly translation / PartStudios -> Create Part Studio translation
This will initiate the actual translation, which may not be finished when you receive the response. If the requestState is ACTIVE you should poll the href (Translations -> Get Translation Status) returned in the response (with a delay between each request) until the requestState returned is DONE or FAILED.
If the translation did not fail, you can then use the resultExternalDataIds field from the response in conjunction with Documents -> Download External Data to retrieve the data created by your translation request.
Please let me know if you have any questions.
Best,
Mike
6
Answers
-
An easy export to Gazebo would be awesome for us as well.0
-
Hi @Doug_Stephen,
Any formats that can be exported through the UI should also be exportable through the API. See below for what you should be looking for in the API Explorer.
Assemblies/PartStudios -> Get Translation Formats
Will return the list of formats that we support for assemblies and part studios. Note that although this request takes an elementId, at this point all elements of the same type will have the same export formats available.
Assemblies -> Create Assembly translation / PartStudios -> Create Part Studio translation
This will initiate the actual translation, which may not be finished when you receive the response. If the requestState is ACTIVE you should poll the href (Translations -> Get Translation Status) returned in the response (with a delay between each request) until the requestState returned is DONE or FAILED.
If the translation did not fail, you can then use the resultExternalDataIds field from the response in conjunction with Documents -> Download External Data to retrieve the data created by your translation request.
Please let me know if you have any questions.
Best,
Mike
6 -
Hey @mthiesmeyer thanks for the help! I was able to use the REST API to trigger creation of a translation for a subassembly on a document, which is awesome! However I'm not able to make the Download External Data call work; I'm using the Java library and I get this exception:
<div>Exception in thread "main" com.onshape.api.exceptions.OnshapeException: Unable to convert media-type application/octet-stream;charset=utf-8 to type class com.onshape.api.responses.DocumentsDownloadExternalDataResponse at com.onshape.api.base.BaseClient.call(BaseClient.java:294) at com.onshape.api.requests.DocumentsDownloadExternalDataRequest$Builder.call(DocumentsDownloadExternalDataRequest.java:72) at us.ihmc.robotics.robotDescription.cad.onShape.OnShapeModelDownloadExample.main(OnShapeModelDownloadExample.java:39)</div>
Not sure if this is me doing something wrong or if there's a hiccup with the Java bindings but I'll keep playing with it and I'll update this post as I learn more.
Quick edit, I *am* able to get to the Collada file if I use the API Explorer from the web app, using the same DID and FID that I'm trying to use from the Java library. So it seems like this may be a bug in the Java library.0 -
Hi @Doug_Stephen,
Sorry about that. I have taken the liberty of filing an issue with the java-client library for you, you can find it here. Please feel free to add any additional information!
Best,
Mike0 -
@mthiesmeyer Thanks for the help, I'll move the discussion to GitHub!0
-
@mthiesmeyer actually I have one last question tangential but still REST API related. I see in the API explorer where I can extract mass properties for Parts, is there an API call to do this for an entire assembly? Or do we have to process that part by part?0
Categories
- All Categories
- 10.2K Community Support
- 4.6K General
- 194 Account and subscriptions
- 353 Data management
- 1.6K Product Feedback
- 215 New in Onshape
- 14 Onshape Labs
- 75 CAM Studio
- 35 PCB Studio
- 107 Simulation
- 209 Onshape Mobile
- 315 App Store & Partners Apps
- 8.2K Using Onshape
- 1.8K Drawings
- 2.3K FeatureScript
- 324 Learning Center
- 253 Education Community

