SolidWorks Quick Tip - Global Variables and Equations

SolidWorks Quick Tip – Global Variables and Equations

Table of Contents


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!

Picture of Terence Woo

Terence Woo

Terence Woo is a product manager at our Hawk Ridge Systems office in Vancouver, British Columbia. He has extensive experience with SOLIDWORKS and SIMULIA analysis tools and helped hundreds of customers solve problems across many industries. When he isnโ€™t working on simulation models, he spends his free time skiing, golfing, rock climbing and playing hockey.
0 0 votes
Article Rating
Subscribe
Notify of
guest

26 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
Dustin
Dustin
3 years ago

Can one control global variables with Excel design tables?

Terence Woo
Terence Woo
3 years ago

You sure can. Just create a column with the correct header. The syntax you need to use is:

$VALUE@global_variable_name@EQUATIONS

Alex
Alex
3 years ago

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
Terence Woo
3 years ago

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.

DC
DC
3 years ago

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
Terence Woo
3 years ago

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
Kirk Charles
3 years ago

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.

Shub
Shub
3 years ago

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
Terence Woo
3 years ago

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.

Roham
Roham
3 years ago

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
Terence Woo
3 years ago

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.

Tiago
Tiago
3 years ago

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
Britto Fernando
3 years ago

Hi Terence can I make Globoidal (double envoloping) worm shaft & worm wheel is solidworks???…Can I use equations for the same

Terence Woo
Terence Woo
3 years ago

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.

BOBBY
BOBBY
3 years ago

Terence,
Can you link to a Global Variable with the Property Tab Builder?

Thank you

BOBBY
BOBBY
3 years ago

I actually solved this by having the prop tab builder write the appropriate text string using SW-File Name.as part of the text string.

Jason Lai
Jason Lai
3 years ago

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
Terence Woo
3 years ago

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@[email protected]”. If this dimension doesn’t exist, you can create a dummy sketch to hold the dimension.

Jeanne McLean
Jeanne McLean
3 years ago

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
Terence Woo
3 years ago

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
Gustavo Assad Barbosa da Rocha
3 years ago

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
Terence Woo
3 years ago

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.

Najet
Najet
3 years ago

Please can you help me how to link assembly global variable to component global variable

Terence Woo
Terence Woo
3 years ago

Najet, you can link an assembly global variable to a component global variable by using the following format for your equation:
“AssemblyVariable” = “[email protected]
(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.

Muller
Muller
3 years ago

Hi,

Can I also use a text as a global variable?

Terence Woo
Terence Woo
3 years ago

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.