Welcome to the Onshape forum! Ask questions and join in the discussions about everything Onshape.

First time visiting? Here are some places to start:
  1. Looking for a certain topic? Check out the categories filter or use Search (upper right).
  2. Need support? Ask a question to our Community Support category.
  3. Please submit support tickets for bugs but you can request improvements in the Product Feedback category.
  4. 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

MBartlett21MBartlett21 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.

mb - draftsman - also FS author: View FeatureScripts
IR for AS/NZS 1100

Answers

  • Caden_ArmstrongCaden_Armstrong Member Posts: 164 PRO

    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?

    www.smartbenchsoftware.com --- fs.place --- Renaissance
    Custom FeatureScript and Onshape Integrated Applications
  • Caden_ArmstrongCaden_Armstrong Member Posts: 164 PRO

    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.

    www.smartbenchsoftware.com --- fs.place --- Renaissance
    Custom FeatureScript and Onshape Integrated Applications
  • MBartlett21MBartlett21 Member, OS Professional, Developers Posts: 2,045 ✭✭✭✭✭

    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.

    mb - draftsman - also FS author: View FeatureScripts
    IR for AS/NZS 1100
Sign In or Register to comment.