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.
Duplicate a document through API
morteza_karimi
Member Posts: 13 ✭
in General
There should be a simple API call to do this but surprisingly isn't.
We have a series of part studios in various documents which are created by multiple people in our organization. We're developing an application that exports these part studios to a different format, but before it does that it needs to do some operations including updating metadata, evaluating featurescript etc. I can do this in the original document and roll back once done but it would create unnecessary history.
I'm aware of the concept of derived parts, but I'm not sure how to achieve that through the API.
But even that is just limited to geometry within the source partstudio. I'd like to bring everything, including custom features into the newly created document.
Does anyone have any workflow for this?
0
Comments
1. User submits did, wid, eid to run export on.
2. On identified d/w/e set an attribute that identifies it as the one the user wants to export. T
3. Call the Copy Document API. This should copy your document and give you the new d/w ids.
4. Find the element that was flagged in step 2 in the new document.
5. Do whatever you need in the copied document in the flagged element.
6. Delete the copied document.
7. Remove the flags from the original document.
Its a couple different API calls but since the APIs are lower level operations its expected that you might need to make a couple different calls.
Could your workflow include creating a version at the state where parts need to be exported? Then you could use api to branch a workspace off that version, make whatever changes needed, export and delete the workspace.
The element id remains the same. Submitting a version for processing also has an advantage that the user can continue working in that workspace without concern for getting exported data in a wrong state.