Welcome to the Onshape forum! Ask questions and join in the discussions about everything Onshape.
First time visiting? Here are some places to start:- Looking for a certain topic? Check out the categories filter or use Search (upper right).
- Need support? Ask a question to our Community Support category.
- Please submit support tickets for bugs but you can request improvements in the Product Feedback category.
- Be respectful, on topic and if you see a problem, Flag it.
If you would like to contact our Community Manager personally, feel free to send a private message or an email.
Import file using Python - API
fluvio_lobo_fenoglietto
Member Posts: 36 PRO
Hello,
I am trying to create a python function that imports a file into an Onshape document.
I have successfully installed and tested demo functions from the GitHub API page, such as app.py.
I have also generated my own version of the file in order to change some of the document attributes.
However, I cannot seem to find "import" or "export" functions that I can call.
Is there any detailed list of functions, function calls?
I am trying to create a python function that imports a file into an Onshape document.
I have successfully installed and tested demo functions from the GitHub API page, such as app.py.
I have also generated my own version of the file in order to change some of the document attributes.
However, I cannot seem to find "import" or "export" functions that I can call.
Is there any detailed list of functions, function calls?
Tagged:
0
Comments
You have two choices for extracting your part studio to another format (Part Studios API in the API Explorer): you can elect to translate it to formats like Solidworks, or STEP (the Get Translations Formats lists the formats we support) Or you can export it to Parasolid or STL formats.
Similar choices and mechanisms exist for an assembly too.
Translation is a batch process, your translation starts and there are APIs to establish the status of the translation (Translations API). Export is an immediate response with the converted data (but the choice of formats is limited).
Thank you! This allowed me to import a data-set into a document that I also created through python.
I have a related question which I really appreciate to get help.
I'm trying to use the existing example (app.py) to import, say an .iges file, and export it as .stl but I can't figure out "element id (eid)" of imported .iges file in either of following methods.
If I create a new document (as it has been done in app.py) the eid seems to be Null. However, sending "null" or "none" to export stl API gives error. Also I can't see a new physical tab in the Chrome as it seems it is happening in the background.
If I use an existing physical tab, I can see that .iges file is imported and 2 new tabs are created, of which one has not preview (only a receipt showing the file is imported), and the other tab seems to be the 'real deal' showing the imported file. However, in this case I can only fetch the eid of the first tab which doesn't help me. Since my intention is to do this in batch.
It will be really nice if someone can help here. Thanks very much!
I believe you need to make a call to api/documents/d/[did]/w/[wid]/elements in order to get the list of elements in the document and get the ID from that. The upload call won't return an element ID as it is made asynchronously.