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.
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.)
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.
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.
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.
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:
But if I forgot to include my units, I get a somewhat less useful 20mm screen:
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.
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!
Can one control global variables with Excel design tables?
You sure can. Just create a column with the correct header. The syntax you need to use is:
$VALUE@global_variable_name@EQUATIONS
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.
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.
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
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.
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.
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
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.
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!
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.
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
Hi Terence can I make Globoidal (double envoloping) worm shaft & worm wheel is solidworks???…Can I use equations for the same
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.
Terence,
Can you link to a Global Variable with the Property Tab Builder?
Thank you
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.
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
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.
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!
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.
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 !
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.
Please can you help me how to link assembly global variable to component global variable
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.
Hi,
Can I also use a text as a global variable?
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.