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 for beginners
lajos_szabó013
Member Posts: 10 EDU
Hi,
I really need some help, since I am struggling hard with Onshape API.
Using VSCode Python I managed to request successfully for new 'Document' and 'Part Studio'. Now it would be nice to have some features inside a 'Part Studio' but I have not found any way to make it work.
I read "Feature List API" (https://onshape-public.github.io/docs/api-adv/featureaccess/) and browsed Glassworks (https://cad.onshape.com/glassworks/explorer/)
From where can I get the right parameters for a /partstudios/.../features API call?
Can anyone send me a link for a detailed documentation about the paramteres, like featureTypes, btTypes with some examples?
Or can anyone help me how to make a cylinder?
Thanks in advance
Lajos
I really need some help, since I am struggling hard with Onshape API.
Using VSCode Python I managed to request successfully for new 'Document' and 'Part Studio'. Now it would be nice to have some features inside a 'Part Studio' but I have not found any way to make it work.
I read "Feature List API" (https://onshape-public.github.io/docs/api-adv/featureaccess/) and browsed Glassworks (https://cad.onshape.com/glassworks/explorer/)
From where can I get the right parameters for a /partstudios/.../features API call?
{
"btType": "string",
"feature": {
"featureId": "string",
"featureType": "string",
"importMicroversion": "string",
"name": "string",
"namespace": "string",
"nodeId": "string",
"parameters": [
{
"importMicroversion": "string",
"nodeId": "string",
"parameterId": "string"
}
],
"returnAfterSubfeatures": true,
"subFeatures": [
"string"
],
"suppressed": true,
"suppressionConfigured": true,
"variableStudioReference": true
},
"libraryVersion": 0,
"microversionSkew": true,
"rejectMicroversionSkew": true,
"serializationVersion": "string",
"sourceMicroversion": "string"
}
Can anyone send me a link for a detailed documentation about the paramteres, like featureTypes, btTypes with some examples?
Or can anyone help me how to make a cylinder?
Thanks in advance
Lajos
0
Answers
Creating features via the API can be complex, given that there are many features with different features. The method I use, is to start is to create a simple model in Onshape, get the list of features, try updating / creating a feature or two.
For example, this document has a cylinder: https://cad.onshape.com/documents/90b779a7c0d90369da933f4a/w/ea9036b3c8be03bf5519fc25/e/eb8e06c33f5da45b743264cd
You can get the features using this API : https://cad.onshape.com/api/v6/partstudios/d/90b779a7c0d90369da933f4a/w/ea9036b3c8be03bf5519fc25/e/eb8e06c33f5da45b743264cd/features?rollbackBarIndex=-1&includeGeometryIds=false&noSketchGeometry=true
Now to update the Extrude depth, I get the feature corresponding to the Extrude and use this endpoint : https://cad.onshape.com/documents/90b779a7c0d90369da933f4a/w/ea9036b3c8be03bf5519fc25/e/eb8e06c33f5da45b743264cd, featureID FPo5vUjLNxbM0Ie_0 and the body here : . Note the actual value changed was the expression from 500->400, but I need to specify all the other parameters as well.
Hope that helps.
thank you for you answer. I do not really get it.
After getting the list of the features from the part the PartStudio how can I formulate the data to make an update on any of the features? I mean you copied this to give all the parameters:
}
I do not know what these parameters are and what they mean. Like what is btType and why is it "BTMParameterQuantity-147"? Or how did you get the nodeId? I made this request ( https://cad.onshape.com/api/v6/partstudios/d/90b779a7c0d90369da933f4a/w/ea9036b3c8be03bf5519fc25/e/eb8e06c33f5da45b743264cd/features?rollbackBarIndex=-1&includeGeometryIds=false&noSketchGeometry=true ), in the respone there is no find for "hE+traOz1uXpwXTY".
I do not know the meaning of this tons of parameter coming back as response. Also do not understand the connection between them and the body of an update request.
Anyway, I am a mechanical engineer trying to make some automation as a part of my MSc. thesis. I have some programming background, but I am not a programmer.
Thank you for your time.
I am getting closer, just successfully managed to change the extrusion depth of a cylinder.
Firstly I did not really unterstand what this sentence was for in the API Usage Details section:
"The feature access and modification API in Onshape presents the internal form of feature definitions rather than providing a translation layer between external form and internal form."
If I understand right this is like having a form of a feature. A feature list request comes back containing not active parameters too with their default expression values, for example thickness or draft angle, even if the used feature is simple solid extrude.
Furthermore, I now perceive like the API documentation contains more details. Maybe I read it hastily before, or you have indeed advanced it.
Thank you again.