SolidWorks Quick Tip - Global Variables and Equations

SolidWorks Quick Tip - Global Variables and Equations
Posted in: Mechanical Design
February 26, 2014

Global variables and equations are a great way to capture design intent and add intelligence to SolidWorks models. If you’re new to global variables and equations in SolidWorks, here’s a quick intro. And if you’re already a pro, check out the NEW items. Both the 2013 and 2014 versions of SolidWorks introduced new functionality for equations.

Global Variables and Equations in SolidWorks - Screen shot

Let’s use a simple example. In this computer monitor model, my first sketch is a rectangle to define the screen and has dimensions for the width and height. However, screens are typically sized by their diagonal length and aspect ratio, not width and height. (Fun fact link if you’re curious about why.)

Global Variables and Equations in SolidWorks - Sketch

To take care of this, the width and height of my rectangle are controlled by global variables and equations. With two variables for “Diagonal Size” and “Aspect Ratio”, and some help from our buddy Pythagoras, I can create a couple of equations to define a 16:9, 20” screen.

Global variables and equations can be created and modified in a few different ways. You can go to Tools > Equations, launch the “Equations, Global Variables, and Dimensions” dialog box, and fill in the table.

Global Variables and Equations in SolidWorks - Tools, Equation Dialog Box

You can also create global variables and equations directly in the “Modify” box of a dimension. Simply type in a name to define a new global variable, or type the = sign to begin a new equation.

Global Variables and Equations in SolidWorks - Modify Box

NEW: One additional place where you can create global variables and equations, which was added in 2013, is directly in PropertyManager fields. Like the “Modify” box, just type in a name or the = sign.

Global Variables and Equations in SolidWorks - Property Manager

NEW: Also added in 2013, global variables can have units! When working with global variables, units are commonly overlooked. This is the one place in SolidWorks where the document units are not automatically added to the values you input. You have to explicitly type in the units. This gives us flexibility, but can be dangerous. For example, when I change the document units from inches to millimetres…

If I remembered to type “in” for inches, I get a 508mm (20”) screen to use as my second monitor:

Global Variables and Equations in SolidWorks - The Importance of Units

But if I forgot to include my units, I get a somewhat less useful 20mm screen:

Global Variables and Equations in SolidWorks - The Importance of Units

NEW: Now what if I want different sizes? With SolidWorks 2014, global variables and equations are now configurable! Similar to dimensions, once you have created multiple configurations, a drop-down menu allows you to select which configurations to change.

Global Variables and Equations in SolidWorks - Multiple Configuration Dropdown

So there’s a quick look at global variables and equations and some of the new options we have available to us. Of course, equations can be used to do a whole lot more in SolidWorks, from controlling the number of pattern instances to conditionally suppressing features with “if” statements. If you’re checking out equations for the first time, a good place to start is the equations tutorial you can access by going to Help > SolidWorks Tutorials. For those of you that have been using equations for a while, leave a comment and let us know what you think of the new enhancements.  Be sure to check out our YouTube channel for more quick tips like this!

February 26, 2014
Did you like this post?
March 4, 2014
Can one control global variables with Excel design tables?
Terence Woo
March 5, 2014
You sure can. Just create a column with the correct header. The syntax you need to use is: $VALUE@global_variable_name@EQUATIONS
June 3, 2014
Terence, Can I control global variables to enforce dimension values in a component of an assembly? I would like to control the diameter of a pipe between two flange components, but I seem to be unable to control that dimension without an extensive macro in design table, which I would like to avoid. I am trying to see if I can get assembly control similar to driveworks xpress without having to carry along a database to run the model.
Terence Woo
June 4, 2014
Alex, you can definitely have assembly global variables control dimensions of components. With the assembly open, simply find the component dimension and apply an equation as you would normally. This will create an external reference to the assembly in the part file. Please let me know if this works for you.
December 1, 2014
Is it possible to pull through all of the global variable and equation names into a design table without manually inputting each one? Some very helpful entries in the Blog Thanks
Terence Woo
December 12, 2014
Try this trick to get global variables and equations into a design table without manually typing each. Make sure you have at least 2 configurations to start, and then configure your global variables and equations in the "Equations, Global Variables, and Dimensions" dialog box. The next time you edit your design table, the "Add Rows and Columns" should appear and you can select your global variables and equations from the "Parameters" list.
Kirk Charles
June 26, 2015
I need to have the mass of parts showing on the assembly drawing. So I have custom parameter called Calculated Mass that is driven by "SW-Mass@GST2B_PIN_WRIST.SLDPRT" This works if all the parts have the same units. But some assemblies have parts in mixed units. How can I create a parameter that will always be converted to the same units (say gms)? Thanks PS it is nice to see the new features.
October 13, 2015
Terence, First of all, I'm impressed by your background in SolidWorks. It's a great achievement. My question is: I have a lot of things automated for drawings in SW. But for example, Description - what happens if the description is too long in the part file and when I make a drawing of the part, the description overshoots the space (rectangular box) defined in the title block? Can I put an IF statement that let's say: IF ( # characters >= 20 in first line) - Insert remaining characters in the second line Can I do this in the title block or template or at the part level where I type in the description (custom property)? Please let me know when you get a chance. Thanks
Terence Woo
November 19, 2015
Sorry for the very slow response. It appears our comment alert system hasn’t been working. Kirk, this is unfortunately a current limitation in SOLIDWORKS. The “SW-Mass” property of each part is linked to the unit system of that part. There is an existing enhancement request to have mass conversion added to a future version of SOLIDWORKS, but for now you’ll have to make sure that your parts use the same units for mass. Shub, the “Wordwrap” option should give you the behaviour you’re looking for. You can specify the wrap width and your note will automatically start a new line when needed.
November 30, 2015
Can you explain why I'm having problems with setting a global variable value? In smart dimension, I go to assign a global variable A. So I put in "=A" (without quotations) for the length of my whole part. I click on the little globe after inputting "=A", and then put in the length of 81 mm. However, when I click on the check mark, SW doesn't define that length as the global variable and only puts 81 for the length. The sigma before the 81 doesn't show, and when I click on the dimension, the globe before the 81 is gone and it's simply a dimension now. Can you please help me with this? I'm running SW 2015 SP 1 x64. Thank you!
Terence Woo
December 3, 2015
Roham, try adding a global variable using the equation manager (Tools > Equations) and then linking the dimension to it. Hopefully that works better for you. However, the steps you described should work. If you want to dig in and figure out why your current process isn't working, a phone call might be easier than comments. If you're a Hawk Ridge Systems customer, give us a call at 877.266.4469. If not, please contact your local VAR.
December 29, 2015
Hi Terence, I have a fully define sketch, and i have a driven dimension ( in grey, that i cannot control), can i tranform it in a global variable? Thank you
Britto Fernando
March 20, 2016
Hi Terence can I make Globoidal (double envoloping) worm shaft & worm wheel is solidworks???...Can I use equations for the same
Terence Woo
March 28, 2016
Tiago, you can link a global variable to a driven dimension, but you'll be controlling the value of the variable with the geometry instead of the other way around. Britto, I'm not sure exactly what you're trying to achieve, but equations can be used in any SOLIDWORKS model.
April 20, 2016
Terence, Can you link to a Global Variable with the Property Tab Builder? Thank you
April 29, 2016
I actually solved this by having the prop tab builder write the appropriate text string using SW-File part of the text string.
Jason Lai
October 6, 2016
Hi Terence, I am trying to link a Global Variable to a Note in a sketch, which can be used to do engraving on a part. I am trying this by using "Link to Property" function in the Note FeatureManager, adding custom property "x_distance", of type "text", referring value to "x@MY_PART_NAME.FILE_EXTENSION". It evaluates to the correct value as set in the "Equations, Global Variables, and Dimensions" window. The problem is, x@MY_PART_NAME.FILE_EXTENSION is engraved instead. I tried property of type "number", but it doesn't allow me to link to the variable x. Hope to hear your suggestion soon. Thanks. Jason
Terence Woo
October 11, 2016
Jason, the current version of SOLIDWORKS doesn't evaluate notes linked to custom properties linked directly to global variables. To get around this, link your custom property to the dimension driven by your global variable instead. It should look something like "D1@Sketch1@Part1.SLDPRT". If this dimension doesn't exist, you can create a dummy sketch to hold the dimension.
Jeanne McLean
November 4, 2016
How can I change the display state of the global variable to read as a letter instead of a dimension number in both the sketch and the drawing? Thank you so much!
Terence Woo
November 9, 2016
Jeanne, unfortunately the name of the global variable that a dimension is linked to cannot be displayed directly. However, you can display dimension names by navigating to "View -> Hide / Show -> Dimension Names". These can be renamed for both sketches and features and the names will propagate to drawings.
Gustavo Assad Barbosa da Rocha
August 24, 2018
Hi Terence ! Is it possible to create a function driven curve, with global variables ? I want to study the different outcomes of changing the variables values on the curves. If yes, I could just change the value of the variable and automatically see the result in the model. Is that possible ? Thank you !
Terence Woo
August 27, 2018
Gustavo, you can link an equation driven curve to a global variable by including the variable name in quotation marks in the equation. After changing the variable, you may need to do a force rebuild (CTRL+Q) to see the curve update.
December 2, 2018
Please can you help me how to link assembly global variable to component global variable
Terence Woo
December 5, 2018
Najet, you can link an assembly global variable to a component global variable by using the following format for your equation: "AssemblyVariable" = "ComponentGlobalVariable@PartName.Part" (Note that the number refers to the component instance in the assembly.) Instead of typing out the equation, you can also simply click on the component global variable in the FeatureManager Design Tree to link to it.
August 16, 2019
Hi, Can I also use a text as a global variable?
Terence Woo
August 16, 2019
Muller, I'm not exactly sure if this is what you're asking, but you cannot assign text as the value for a global variable. Perhaps you can achieve what you're looking for by using custom properties.

Please to comment.

Don't have an account?