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.
How do i use the API to update dimensions of parts
kristofer_henry
Member Posts: 3 EDU
I've been crawling through the API documentation for a couple of days now and have made not much process,
I'm not sure what the correct way to go about this is but I've planned on a few ways:
designing the original part with variables and then using the API to modify them,
using the API to create configurations and then apply them,
using the API to create a variable table and then applying it to the part studio (I've only managed to create the tables )
I want to eventually be able to create a web app that takes in variables and spits out a drawing and a model view but I got stuck on the first step
I'm not sure what the correct way to go about this is but I've planned on a few ways:
designing the original part with variables and then using the API to modify them,
using the API to create configurations and then apply them,
using the API to create a variable table and then applying it to the part studio (I've only managed to create the tables )
I want to eventually be able to create a web app that takes in variables and spits out a drawing and a model view but I got stuck on the first step
0
Best Answer
-
FelixDeng Member Posts: 2 PROHi Kristofer,
If you are trying to vary the parameters of a few set variables, it will be easier and more efficient to create and use configurations with the API. Here is an example explaining the process: https://colab.research.google.com/drive/1R4qOvODWP3PA0tDm-EfPtmK6Gz4TtYJm.
If you are working with more complex edits on the features with the API, here is an example on editing the features with the API: https://colab.research.google.com/drive/1wjBwRDyDiMiF9Nz0g8MZ49HgAbDhcUfp.
All examples are written in Python (in Jupyter notebook format) with the requests library (https://requests.readthedocs.io/en/latest/). There are also some useful API endpoints listed here if you are using a variable studio: https://cad.onshape.com/glassworks/explorer/#/Variables.1
Answers
Your approach seems reasonable.
We have a sample application that demonstrates how to do some of what you are asking : https://github.com/onshape-public/configurator-example, live example : https://configurator.onshape.app/configurator/9558507b2d8feaea012281be/v/ef47a69cee64730a99017b43/e/a8d9da8f108b44b9fa903800
>> I got stuck on the first step
It may help to share what you tried and where you got stuck for someone to be able to help you.
I've been able to grab info about documents and elements, even create and modify variable studios but I haven't been able to change set variables inside part studios,
the example includes the functionality that I am looking for but i haven't had much success reading through the code since I'm not familiar with typescript.
the problem might be that i am lacking fundamental knowledge of the inner workings of OnShape.
is there an example out there of how to do something similar like this through raw HTTPS requests without the use of a library,
https://cad.onshape.com/glassworks/explorer#/
If you are trying to vary the parameters of a few set variables, it will be easier and more efficient to create and use configurations with the API. Here is an example explaining the process: https://colab.research.google.com/drive/1R4qOvODWP3PA0tDm-EfPtmK6Gz4TtYJm.
If you are working with more complex edits on the features with the API, here is an example on editing the features with the API: https://colab.research.google.com/drive/1wjBwRDyDiMiF9Nz0g8MZ49HgAbDhcUfp.
All examples are written in Python (in Jupyter notebook format) with the requests library (https://requests.readthedocs.io/en/latest/). There are also some useful API endpoints listed here if you are using a variable studio: https://cad.onshape.com/glassworks/explorer/#/Variables.