Report sketch regeneration error to featurescript

evan_yu363
evan_yu363 Member Posts: 3 ✭
Is there a way I could programmatically determine (ex. in featurescript) whether a sketch has failed to regenerate?

Context:
I'm trying to perform a computational optimization on a design by programmatically testing/searching a design space defined by onshape configurations. Certain configurations may be invalid, for example creating a triangle with side lengths 100, 100, 1000 (example of sketch failure being difficult to diagnose https://cad.onshape.com/documents/f885f435a14a2bdc0fb5b270/w/2f134941bb9f61f678806f3f/e/21205e69d39971ee6aea2d06). These invalid configurations usually cause sketches to fail to regenerate. In this way, the sketch can be considered a geometric constraint on the design/configuration space.

Currently when a sketch fails to regenerate, it returns to some default sketch which allows downstream features to regenerate correctly. This makes it difficult for me to programmatically determine whether a configuration is valid or not. Thus, I am looking for some solution to identify sketch failures.

A temporary solution I've found is to place mate connectors at the "default" sketch locations and determine failure by when a configuration does not move the mate connectors (by evaluating distance in Featurescript). However since I cannot control the "default" sketch, I can't trust this approach to consistently work.

Comments

  • NeilCooke
    NeilCooke Moderator, Onshape Employees Posts: 6,126 image
    FS can only create or modify geometry. There’s no way to interrogate features as it cannot access their definitions. 
    Senior Director, Technical Services, EMEA