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.
Drawings/create API
shawn_crocker
Member, OS Professional Posts: 869 PRO
in General
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.
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.
0
Best Answer
-
shawn_crocker Member, OS Professional Posts: 869 PROJust 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.0
Answers
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.
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.
I haven't tried but, possibly only having a single top view in your template that you use for the call will work?
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
Did you end up figuring this out? I want to do the same thing (except with 2 views).
Things got busy so I stopped working on it,.. A quick fix would be to just place the 4 views- get their view Ids using another endpoint- and then delete the unwanted views… I tested it in glassworks and it seems to be working as intended but I'm almost certain that this will not work in a real script because it will be very slow
@Christopher_Ace_Caoile That's a good idea. It would be cool though, if an Onshape developer could step in here to be clear on how it can be done efficiently or if it can be done. It would seem it should be able to be done, simply because it is being done within the Onshape UI. Sadly much of the API calls being done within the Onshape UI seem to be made server side, so picking through your console to see what is actually happening is not much help with respect to drawings I have found.