SolidWorks: Global Variables
When designing in SolidWorks, there is always something you can do to help increase your efficiency. One such tool is the use of global variables. If you create parts that go through many stages of updates, global variables can save you time. Not only can it help save time, but if set up properly it helps reduce the chance of missing or incorrectly updating a component or feature.
To begin, I will show you how to set up a global variable in a sketch dimension. To create a global variable, first go to Tools → Equations. You should now see the following window pop up.
Click on the white box that has the grey “Add global variable” text, under the “Name” column, to activate it. Enter in whatever you would like your variable to be called and hit Enter on your keyboard. You will now be in the “Value / Equation” column. Enter in the value you would like for your variable, such as your desired dimension and hit Enter. You can repeat this process for however many variables you would like to set up.
Note: When entering the value, if you do not enter a unit along with the value, it will default to your document unit settings. If you do enter units along with the value, it will remain that unit regardless of how you modify your document’s unit settings.
Now we can apply this global variable to a dimension on a sketch. Sketch an entity and apply a dimension, prompting the Modify dialogue window to open. Instead of typing a value in the dimension box, as you normally would, type an equal sign. The following drop-down should appear.
You can then select from your list of global variables that you have created and confirm the dimension as you have done before. As an alternative, you can also type your variable rather than selecting from the list. If you do this, be sure to enter the variable name in quotations, i.e. =“OD”. Your variable will now have an equation symbol prior to the value.
Equations can also be entered as global variables. For example, consider an extrusion in which the inner diameter is always to be half that of the outer diameter. Go back to Tools → Equations and create a new global variable. Now, rather than entering a value, enter your equation.
You can confirm by checking the “Evaluates to” column to ensure the equation comes out to the right value. You can now apply this global variable, just as you would with the original variable. We now have a part that will always have the same outer diameter to inner diameter ratio and can be updated just by updating the outer diameter.
This is just an extremely basic use case. You can have variables and equations relating variables to each other for every dimension you desire in a part. Another potential use is if you have a part that will have a shared dimension among various features. Setting them all up with a global variable will make updating them a breeze. However, make sure you know this is the desired design intent or else you will waste time going in and deleting the equations that are restricting your work.
Thank you for taking the time to read our blog. If you have any questions or require our contract services, please don't hesitate to contact us.