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.
API Support for C# Application

Good morning,
I have been going through the examples for the API and looking for a little help / guidance from the community on how to accomplish my sample task.
In essence I am trying to create a new drawing, insert 2 sample DWG blocks inside it at specific coordinates, and then export the drawing to an Azure BLOB. All of this needs to be done programmatically using API calls with JSON from my application.
- I can create the drawing (Example.dwg).
- I can add an OnShape Drawing (Tab) to the file (Called TestDrawing). This TestDrawing is small (looks like 8.5 x 11), so any help on how to modify the JSON call to make a larger drawing, or one based on a DWG title block, would be very helpful!
- I can't yet insert test blocks onto the TestDrawing. The files are located in a folder BlockLibrary and called Test1.dwg and Test2.dwg. I can get the Document ID and Workspace ID of the Test1 and Test2 files, just can't get the JSON insertion to work.
- Haven't gotten this far, but next step would be to export TestDrawing as a DWG to an Azure Blob Storage. I've got code ready to try to turn the file into a MemoryStream and send to a Blob, just haven't tested it out yet.
- var request = new RestRequest($"drawings/{drawingId}/export", Method.Get);
- var response = await client.ExecuteAsync(request);
- return new MemoryStream(response.RawBytes);
- var request = new RestRequest($"drawings/{drawingId}/export", Method.Get);
Thanks for any help you can provide on the API / JSON calls!
Best regards,
Richard
Answers
Hi Richard,
We currently do not support inserting DWG blocks into Drawings via the API. You might try creating a template with the DWG blocks and creating a drawing from that template, using these steps:
https://onshape-public.github.io/docs/api-adv/drawings/#create-a-drawing-from-a-template
Susan Pedicini
Onshape Technical Writer
Hi Susan,
Thank you for the reply- maybe I can explain what I'm trying to do and you can let me know if it seems like a supported use case of the API and OnShape- I have an application which I would like to have programmatically create a drawing; take a bookshelf for example.
In essence, programmatically creating the drawing, and the initial thought was to have the components in DXF/DWG format for insertion at coordinates as necessary but sounds like that's not an option unfortunately. Are there any other ways you might suggest approaching this problem with OnShape API?
Thank you,
Richard
Hi Richard,
You can use configurations to insert specific Part or Assembly options. You can read about how configurations work here:
Susan