SolidWorks 2011 Parts Bible - Matt Lombard [150]
Assigning a link value or a global variable as a link value
You can use custom and file properties to drive equations. If you right-click your Equations folder and select Show Properties, you see that the default file properties already exist in the list, shown in Figure 10.15:
Global Variable
Custom Property
Default File Property
FIGURE 10.15
Equations and properties
In the equation editor shown on the right in Figure 10.15, you can expand the list of global, custom, and default properties for easy selection and placement into equations. Any custom properties you add that are of the type “number” are automatically added to this list and can be used in equations. Notice that the custom property “cost” is a property saved in my template and gets picked up for use here.
Note that you can assign both a custom property and a global variable with the same name. The global variable will take precedence over the custom property to evaluate an equation.
Starting in SolidWorks 2011, global variables are now configurable. Chapter 11 covers this feature in more detail, but the syntax for using a design table to drive a global variable is as follows:
$VALUE@global_variable_name@equations
Using Expressions
Expressions, unlike all the previous variables, values, and equations, can be entered directly into dimension dialog boxes in the Modify dialog box and PropertyManager value boxes. The expressions have to be composed of numbers and mathematical operators. An expression such as
2.375+(4.8/3) -1.1
is perfectly acceptable, as is
1+1/2
or
1 1/2
In the second case in this example, the plus symbol is understood.
Other types of operations are also available, such as ones for changing units in a dimension box. For example, if you are editing a part in inches, and enter 40mm, then SolidWorks does the conversion for you. You can even mix units in a single expression such as 4.875+3.5mm, where the inch part is assumed as the document units.
SolidWorks does not remember the expression itself, only the final value. Expressions can be entered into any place where you enter dimensions for SolidWorks features.
Controlling Suppression States of Features
You can use the IIF statement described earlier in this chapter to control suppression states of features and components. An example of the syntax is:
Figure 10.16 shows this type of equation in use. Keep in mind that the quotes are important. On the DVD The part used in Figure 10.16 is on the DVD with the filename Chapter 10 – IIF Suppress.sldprt. You can also use this equation in assemblies to control suppression states of components (parts and subassemblies). FIGURE 10.16 Using IIF to control suppression states Linking to External Equations You can use externally saved equations to share equations between models. To export an equation, click the Export button in the lower-right corner of the Equations dialog box, as shown in Figure 10.16. To link the current model to the externally saved equation, make sure the Link To File option is checked at the bottom of the Equation Export dialog box, as shown in Figure 10.17. FIGURE 10.17 Saving an equation to an external file To link to an existing equation from a SolidWorks model, use the Import button in the Equations dialog box. Also be aware that only equations and global variables can be shared in this way. Link values cannot be shared. Tutorial: Using Equations Follow these steps to get some practice with using equations: 1. Start from the part on the DVD with the
The equation is saved to a simple *.txt file. The default name for the external equation text file is equations.txt. You can change the name if you like, but remember that if you use Windows Explorer to change the name or change it with the referencing file closed, SolidWorks will not know that the filename has been changed. At the bottom of the Equations dialog box is a path for a linked equation file. You can only link to one equation file at a time.