Global variables in Solidworks refer to linked values that you can use in a model. It follows the same concept as in basic mathematics and computer programming. In Solidworks, global variables make modifying the dimensions of your model easier.
Let us use a case study of a simple cylinder. In mathematics, the volume of a cylinder is the product of the base area and the height:
where D=diameter of the circular part of the cylinder, and
H= height of the cylinder.
Let us assume that the height (H)=2*D
To define our variables, D= 50mm, H=2*50mm= 100mm
The calculated volume of the cylinder would then be 196,349.54mm3
Let’s validate this in Solidworks.
How To Use Global Variables In Solidworks.
Step 1: Open the Solidworks software, create a new part, and start a sketch on the top plane. You can save the part at this point.
Step 2: Draw a centre point circle (circled red) at the origin. Select “Smart Dimension” and click on the circle. Instead of typing a value immediately, we will type the word “Diameter” in the dialogue box. Solidworks would then ask if we want to create a Global variable. Click ‘yes’.
Step 3: Input the dimension of the diameter (D) we earlier defined, 50mm. On the design tree, you will notice that “Equations” was added to the tree and the variable, “Diameter”, was assigned the value of 50. Also, a symbol (∑) appeared beside the diameter value (circled green), indicating that the dimension is a global variable.
Step 4: To complete the cylinder, we move to the features tab and click on “Extruded Boss/Base”. Like in steps 2 and 3, we will create a new global variable called “Height”. At this stage, instead of assigning a value, leave the default value as is. In the next step, we will see how to use equations.
Step 5: In the design tree, right-click on Equations and click on “Manage Equations”. A new screen would appear.
Step 6: In the new screen, you would see both variables, Diameter and Height, under Global Variables. Their respective values are in the “Value/Equation” column. From the mathematical equations defined above, the height of the cylinder should be twice the diameter of the circular face.
The equation should be written following the syntax in the images below, under “the “Value/Equation” column.
Step 7: The Height variable evaluates to 100mm. If the diameter of the circle is updated, the height automatically updates.
Bonus: Let us now compare our calculated volume with Solidworks’ value. Go to the Measure tab and select “Mass Properties”.
The values are the same! You can play around with various equations, simple and complex.