Defining feature types

Features are the fundamental unit of CAD, and they are also the fundamental unit of FeatureScript. The FeatureScript inside a feature type can encompass anything from attaching some commonly used geometry, to wrapping one of Onshape's features in a more convenient interface, to generating a full part in one feature.

The input to this feature type is defined in the precondition block of code, which defines a one-dimensional length parameter named "Fillet radius".

The behavior of the feature is defined in the bottom block of code. The statement inside that block calls the opFillet operation (the same one used in Onshape's fillet feature). The radius of the fillet is set to the filletRadius provided by the user. The entities to fillet are defined with a Query for every edge in the Part Studio.

The FeatureScript inside a custom feature gets executed as part of the Part Studio's regeneration. This means the code inside the feature type function will run for every instance of the feature, every time its context or its definition changes, including:

When the feature is first added.

When one of its definition's parameters (i.e. filletRadius) gets updated.

When any upstream feature is modified, deleted, or suppressed

When the rollback bar moves from before to after the feature

Moving the Fillet Everything feature up in the feature tree will cause it to fillet only the edges which were defined when the Fillet Everything feature was created:

Suppressing an extrude above the Fillet Everything feature (and thus removing edges) notably will NOT cause the Fillet Everything feature to break with an error like "missing edges". This is because no explicit references to the edges are passed into or stored by the feature. Rather, the feature reevaluates the edge Query every time the feature is run.