Reading feature related infromation
Kirankumar_Thimmegowda
Member Posts: 28 PRO
Is there any way to get the information added in feature script(samples below) through api.
throw regenError("This is a regen error");
throw regenError("This is a regen error");
reportFeatureInfo(context, id, "Some error found");
https://cad.onshape.com/documents/a63f2300d0234e62b89f906d/w/1432bb01183f19577aa937e2/e/32e2592e0830a05993a8a875
https://cad.onshape.com/documents/a63f2300d0234e62b89f906d/w/1432bb01183f19577aa937e2/e/32e2592e0830a05993a8a875
Tagged:
0
Answers
-
Are you trying to test if a part studio has errored via a regenError thrown by a custom feature via the Onshape API?
Software Developer at Epic SystemsFRC Design Mentor - Team 10553 Orange Overdrive0 -
@Alex_Kempen,
Basically i want to access information added as string(inside catch block through reportfeaturewarning, throw regenerror or any other better way) through api0 -
Okay, a couple things. If you throw a regenError, the part studio will stop regenerating and report an error state. It's possible the error message thrown is accessible via a documents or part studio endpoint; you can play around with glassworks and a part studio with an error to see if the information is available.
https://cad.onshape.com/glassworks/explorer/#/
Otherwise, the standard way of extracting strings (possibly set via a custom FeatureScript) is by using the PartStudio featurescript endpoint, which takes a feature script function and evaluates it against a fully finished PartStudio. You can use this to fetch attributes or variables set via a custom feature, or compute information you need directly (using queries and whatnot).
Software Developer at Epic SystemsFRC Design Mentor - Team 10553 Orange Overdrive0 -
The api endpoint for /partstudios/.../features gives the "featureStates" property. But it only give if the feature has an error, but not what the error is.
Like Alex suggested, if you want the specific error, you would need to store it somehow - like in an attribute or variable that can be retrieved via the /api/partstudios/.../featurescript endpoint.0

