Query Variable
Create a parametric selection group for use in a Part Studio. Query variables enable you to dynamically define the selections to be used in downstream features. You can choose manual selections, from a set of selection criteria, solid bodies and edges by convexity type, or all entities of a given type created by another upstream feature. Any changes to the query variable are automatically reflected in all downstream features. Selections can also be combined with union, subtraction, and intersection operations.

-
Click the Query Variable button
to open the Query Variable dialog:
-
Enter a name for the query variable.
-
(Optional) Enter a description for the query variable.
-
Click the Selection type dropdown and choose Selection.
See the Examples below for details on other Selection types.
-
Click the entities to add to the group.
-
(Optional) See the Add additional queries section below for information on combining query logic.
-
(Optional) Select Evaluate on use to reevaluate the query each time it's used. By default, this option is not selected, and the query variable only selects the currently selected entities, even if it's used at a later point.
For example, if you create a query variable with the All solid bodies selection type, with a single cube in the Part Studio, the variable will only refer to the cube, even if you add more solid bodies downstream. With the option selected, the query will update to include all solid bodies in the Part Studio at the time of use. -
(Optional) Deselect Show selection to remove the automatic selection highlights.
-
Click the green check mark to close the dialog.
Now, you can use the new variable you created in other dialogs.
Changes made to the query variable selection are automatically updated in your document downstream. In the first image, a new vertex and face are added to the selection. Once the green check mark is clicked, the dialog closes and the downstream extrude automatically updates with the new selection, as shown in the second image.

-
Double-click the query variable in the Features list to open the Query Variable dialog.
- Make changes as needed.
-
Click the Final button at the bottom of the dialog to preview the downstream changes. (This option is not available if the query is the last feature before the rollback bar.)
- Click the green check mark to save your changes, or click the X button to close without saving.

You can apply logic to the Query Variable dialog to select the union, subtraction, or intersection of entities.
-
In the Query Variable dialog, click the Add additional queries checkbox to expand the section.
-
Click the Add additional query button.
-
Select from one of the following:
-
Union - Select everything in the original query and this additional query.
-
Subtract - Select everything in the original query, minus anything selected in this additional query.
-
Intersection - Select only entities included in both queries.
-
-
Add the additional query as instructed in the Basic steps section.
-
Continue clicking the Add additional query button for each query you want to add.
Union
This query selects everything in both the #horizontal and #vertical query variables.
Subtract
This query selects everything in the #horizontal query, minus the one shared part from the #vertical query variable.
Intersection
This query selects only the entities shared by both the #horizontal and #vertical query variables.


-
In the Query Variable dialog, click the Selection type dropdown and choose one of the following options:
-
Created by - Choose all entities created by another feature
-
Owned by - Choose all entities owned by another entity.
-
-
Select the creating features or owning entities in the Onshape window or Features list.
-
Select Vertex, Edge, Face, or Body from the Entity type dropdown to specify which entities to include in the selection.
-
Optionally, when using the Created by option, uncheck the Filter construction entities check box to include sketch construction entities in the variable. With the box checked, the variable only selects non-construction entities.
Below, the #pegs query variable is used as the merge scope for the holes:

In the Query Variable dialog, click the Selection type dropdown and choose one of the following options:
- Protrusion - Selects all faces that are connected to the selected face by a convex edge.
- Pocket - Selects all faces that are connected to the selected face by a concave edge.
- Hole
- Selects all faces that are connected to the selected face as part of the same round hole.
- Fillets - Selects all faces on a part which form a constant radius fillet.
- Bounded faces - Selects all faces between the selected face and the boundary defined by other edges and faces selected. In the Faces field, select a seed face that touches the desired region of faces. In the Bounds field, select all edges or faces which bound the desired region of faces:
The second selection defines the boundary. All adjacent faces and edges are captured in this selection set to form a closed boundary. If a close boundary cannot be formed, all adjacent faces and edges are selected.
-
Loop/chain connected - Select a face (and/or sketch edges). All edges that form a connected loop on that face (or adjacent to the sketch edge) are selected. Select adjacent faces (or sketch edges) to continue the loop.
- Parallel - Selects all edges parallel to the selected edge.
- Tangent connected - Selects all edges tangent to the selected edge.
- Matching - Select a face or edge and all faces and edge that are the same size are selected.

In the Query Variable dialog, click the Selection type dropdown and choose All solid bodies. All solid bodies in the Part Studio are added to the selection:
Below, the #solid-bodies query variable is used to transform the parts, but not the surface:

Edge convexity refers to the angle between the faces bordering an edge. The selection for the case is the bodies from which to filter the edges.
-
In the Query Variable dialog, click the Selection type dropdown and choose Edge convexity.
-
With focus in the Entities field, select the bodies from which to filter the edges.
-
Select Convex, Concave, Smooth, or Variable from the Edge convexity type dropdown to specify which type of edges to include in the selection. Variable convexity indicates that the edge includes both convex and concave sections.
Query variable that selects all convex edges in the part.
Query variable that selects all concave edges within the part.
Query variable that selects all smooth edges within the part.

- Query variables can contain multiple selection types (e.g., edges, faces, vertices, bodies).
- Query variables can contain entity types not expected by a feature (e.g., a query variable that contains edges and vertices can be consumed by a fillet).
- Empty query variables are allowed.
-
Define a query variable close to where you want to use it for greater control.
-
When a query value contains multiple valid selections, the first valid entry is used on evaluation. For example, if a query variable contains all three default planes and is used to define a sketch plane, the first valid plane is used.
Query variable evaluates to the Top plane.
