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.

Drawings/create API

shawn_crockershawn_crocker Member, OS Professional Posts: 861 PRO
I have been adding some functionality to an app that allows a user to initiate the creation of a new drawing of a selected item from within the app.  Seems to be working really good.  Only thing is I cannot seem to get the new drawing to get created using a selected template.  See image.



I have templates and I have supplied the appropriate details to the highlight keys in the image.  But still, the drawing is created with a default onshape template.  When I use the "templateName" key, the query reruns a 400.  When I omit that key it works.  I'm thinking I am not understanding exactly what should go into the key.  Does anyone have any ideas?  I know drawings endpoint are supposedly not fully stable and it is not completely suggested to use them but I am hoping someone out there figured out how to make the template part work.  It would be so perfect to be able to stop manually changing the template every time.
Tagged:

Best Answer

  • shawn_crockershawn_crocker Member, OS Professional Posts: 861 PRO
    Answer ✓
    Just figured it out.  I tried using "templateWorkspaceId".  Now the drawing gets created with the right template.  It is strange the versionId doesn't work.  Based on how the system works as a whole, I am surprise we are even able to reference the workspace like this.

Answers

  • Bob_MinerBob_Miner Member, Onshape Employees Posts: 4
    @shawn_crocker - Could you please try passing just the templateElementId, templateWorkspaceId (or templateVersionId) and the templateElementId.  I don't think you need the templateName.  Thanks.

  • shawn_crockershawn_crocker Member, OS Professional Posts: 861 PRO
    @Bob_Miner
    I have been doing that.  I am currently using it without the "templateName" key.  Everything runs as expected except the newly created drawing is set with a default template.  This is the issue.  That the template I am choosing does not seem to be getting read by the server or something.
  • shawn_crockershawn_crocker Member, OS Professional Posts: 861 PRO
    edited March 2023
    I'm just discovering drawing BOM's are very huge.  One letter takes up the whole drawing sheet.  Looking at the drawing properties after loading in my standard template, text size and everything seems to be correct but still the text of the BOM is gigantic.


  • shawn_crockershawn_crocker Member, OS Professional Posts: 861 PRO
    edited March 2023
    Just noticed, I have to use the "unit" key and supply the desired unit system.  I was thinking this was going to be attached to the template I was manually switching to.  Seems the bom scale is being driven by a unit that is not coupled to the unit set in the drawing properties.
  • shawn_crockershawn_crocker Member, OS Professional Posts: 861 PRO
    Answer ✓
    Just figured it out.  I tried using "templateWorkspaceId".  Now the drawing gets created with the right template.  It is strange the versionId doesn't work.  Based on how the system works as a whole, I am surprise we are even able to reference the workspace like this.
  • Christopher_Ace_CaoileChristopher_Ace_Caoile Member Posts: 4

    Still on the topic of creating drawings using this endpoint… How do I add just a single view? I'm trying to create a drawing for a flat sheet metal, so I need to show just the top view, but it's giving me 4 standard views when I use it.

  • shawn_crockershawn_crocker Member, OS Professional Posts: 861 PRO

    I haven't tried but, possibly only having a single top view in your template that you use for the call will work?

  • susan_pedicinisusan_pedicini Member, Onshape Employees Posts: 3

    Try the steps here for creating a custom view template: https://onshape-public.github.io/docs/api-adv/drawings/#create-a-drawing-in-a-custom-graphics-area

Sign In or Register to comment.