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.
Replacing drawing reference through the API
MBartlett21
Member, OS Professional, Developers Posts: 2,045 ✭✭✭✭✭
Is there a documented way to update drawing references through the API?
I've tried both of the below:
- POST /appelements/d/{did}/w/{wid}/e/{eid}/references/{refid}
- The result was either "error generating query for deterministicId" or "An internal error has occurred; support code xxxx" or sometimes a message object about "must not be blank", depending on which parameters I tried to pass
- POST/elements/d/{did}/w/{eid}/e/{eid}/updatereferences (seems like it should be the more correct way)
- The result was always nothing, and it appeared to update the reference in the drawing, but the new reference always failed to resolve.
0
Answers
My Renaissance app has a function that duplicates drawings and modifies the configurations to generate "configured" drawings.
I'm using the endpoint:
POST /appelements/d/{did}/w/{wid}/e/{eid}/references/{refid}
and my body is:
referenceId
targetConfiguration
From playing around with drawing references, most fields aren't supported.
What in the reference are you trying to update?
Custom FeatureScript and Onshape Integrated Applications
Actually, I played around with this a bit more and you can update references in some scenarios.
I've only been able to get drawing references that reference the current document/workspace to go, but you can do a body like:
POST /appelements/d/{did}/w/{wid}/e/{eid}/references/{refid}
{
"targetElementId": "3e1aaa9584e18f3f590b71d9"
}
Where only the targetElementId is modified.
And the view/sheet reference will update to the new element, assuming everything is valid without changing the microversion of the document.
I think a word of caution is appropriate here, I may have put the drawing into a broken state a few times messing around with this stuff.
Custom FeatureScript and Onshape Integrated Applications
My idea was trying to duplicate drawings and then replace references, so that I could create a drawing with a particular view layout (rather than the default four views). I'll try trimming the reference updates down and see what that does for me.
IR for AS/NZS 1100