I’m often asked if design rules can be created in Onshape. The answer is yes. These rules can be as simple as relating two dimensions together with a simple equation (i.e., width = length/2). 

In this Tech Tip, you will see a more sophisticated example of applying a design rule in Onshape using variables, expressions, and arrays.

Creating a Design Rule

For the power strip design shown in the image below, it is essential that the number of receptacles and the number of reinforcing ribs be appropriate for the length of the strip.

power strip designed in CAD

Notice the variables in the Feature list: #Length_Selector, #Receptacle_Count, and #Rib_Count. These are number-type variables because they do not represent dimensions.

Feature list in Onshape

In the image below, the strip length is controlled by a specific set of values contained in an array. In the expression [130mm, 161mm, 225mm][#LengthSelector], the first set of brackets is an array containing the three allowed strip lengths. The variable #Length_Selector serves as an index that indicates which value from the array to use for the strip length. Indexes always start with 0. If 0 is entered for #Length_Selector, the strip length is 130mm. If 1 is entered, the strip length is 161mm, and so on. This establishes a design rule for the strip length.

Variables

You can now create two more expressions to control the number of receptacles and ribs. For these, edit the variables and enter the appropriate number of instances for each value of #Length_Selector.

For the receptacles:

Receptacle count

For the ribs:

Rib count

These two expressions use the value #Length_Selector to create the appropriate number of receptacles and ribs. The strip now has the correct number of receptacles and ribs when the length changes. Remember that you can view and edit variables from the flyout panel on the left. Double-click cells to show the expressions you entered.

Variable table

Watch the video below to see this Tech Tip in action.

This Tech Tip helped you learn how to create design rules using variables, expressions, and arrays. Take the Onshape Learning Center course Variables and Expressions to learn more about this topic. 

Interested in learning more Onshape Tech Tips? You can review the most recent technical blogs here

Friends Don’t Let Friends Use Old CAD!

Know a colleague who could benefit from our cloud-native, fully-featured collaborative design platform?