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.
Best way to get part a feature is related to
Cappie_Pomeroy
Member Posts: 14 ✭
I am using FeatureScript and the Onshape API to define measurements that need to be taken on parts and track them through our production process. I am in general very pleased that Onshape has developed these tools because managing this in other CAD programs was so nightmarish we avoided it entirely. Right now I am using a slightly customized version of Measure Distance Extended https://cad.onshape.com/documents/77baa8153589a7fc5f289829/w/cffd0f2a7077380d5378a885/e/d3174bf5315e6aafcb889367 I have added another precondition to attempt to restrict the measurement to a single Part via
annotation{ "Name" : "Part", "Filter" : EntityType.BODY && BodyType.SOLID, "MaxNumberOfPicks" : 1 }<br>definition.part is Query;<br>It is unclear to me how to restrict the remaining selections to be only on that part any advice on that would be useful, but I'm sure it's just more digging through the docs. My more pressing question is about API calls. Currently my work flow from my cloud integrated app is
- GET part_studios in document
- Iterate over part_studios and GET features_list
- Filter features_list for "measureValue" features, pull out name, partId, and microversion
- GET parts from part_studio measureValue feature was in, look for the partId, pull out part name
- POST featurescript to evaluate measureValue varible value for each measureValue feature name
{<br> "featureId": "String",<br> "name": "String",<br> "value": Number,<br> "unit": "String"<br> "part_id": "String",<br> "part_name": "String",<br> "microversion": "String",<br> "serializationVersion": "String<br>}<br> <br>Then the user tweaks things how they want and I send it off to our database and it populates our various measurement UIs etc.
Is there a better work flow for this? 4 API calls + extra for each additional FeatureScript variable and Part Studio seems like a lot.
Thanks!
0
Comments
To your first question, I'm quite sure there is no way to have the precondition filter based on the selection of the previously entered query param. You can only filter based on the geometry/entity types as specified in https://cad.onshape.com/FsDoc/uispec.html . Therefore the best way to do this is to fail the feature and set the problem geometry in the error. I cooked up a short example here: https://cad.onshape.com/documents/35d3454cea522f3aad260f55/w/92947cbb34b76fb048910110/e/588987397d874076e058b96f
As for the second question, am I right in thinking that all you need is to extract the actual measurements? The strategy that has been taken before is to put all the measurements under a single variable (usually a map), and then retrieve that variable using the evaluateFeaturescript call. This way you only have to make one call per part studio. See here for an example using the python client: https://github.com/onshape-public/onshape-clients/blob/master/python/onshape_client/example_programs/get_measurements.py
Let me know if you need any more pointers!
Correct, at a given version or microversion, those ids will always refer to the same parts. Versions and microversions are immutable in every way that can effect these ids.
They are called "transient" because they may change whenever the model changes. So, for different microversions, or at different points in regeneration (i.e. before and after a feature, or before and after some operations inside a custom feature), those ids may not be stable. But in a version or microversion, the model can't change, so neither can those ids.