Chapter 9. Using Equations

IN THIS CHAPTER

  • Understanding equations

  • Link values

  • Global variables

  • Expressions

  • Tutorial: Equations

Parametric sketch relations are not the only way to drive dimensions with intelligence. You can also use equations, link values, and global variables. Equations help you to create simple or complex mathematical relations between dimensions. Link values are essentially a quick way of making two dimensions equal. Global variables can be used in equations like other dimension names. These three techniques are all very similar and related to one another in the interface, but are used in different ways in different situations.

Equations are a very powerful extension of the set of parametric power tools that SolidWorks offers to users. If you are not accustomed to driving dimensions with equations, then you may find it challenging to get the order of equations correct so that dimensions are not changed multiple times when more than a few equations are involved.

Understanding Equations

Understanding Equations
The Equations interface

Figure 9.1. The Equations interface

Using the Equations interface, you can turn off equations temporarily by deselecting the Active check box in front of the equation. Equations can also be deactivated by a design table. I will discuss design tables in more detail in Chapter 10, which discusses configurations.

Note

Although I do not cover configurations until Chapter 10, I will mention this here. Equations and configurations (particularly those that are driven by a design table) should probably not be mixed. This is not because they do not work together, but more for the sake of organization. When controlling dimensions, it can become confusing if the changes are being driven from multiple sources. Also, there is no reason not to bring your equations into Excel rather than using the comparatively limited equation functionality offered by SolidWorks.

Creating equations

Equations are easy to create and useful for many purposes. A common situation where you would use an equation is to space a pattern of holes evenly along an edge, including the gap on both ends, where the gap at the ends is half of the regular spacing. Before you write an equation, you need to take care of a few organizational details.

Naming dimensions

It is not necessary to name every entity in every SolidWorks document, but you should get in the habit of naming important features, sketches, and even dimensions. Dimensions become particularly important when you use equations, configurations, and design tables. Under most circumstances, you do not use or even see dimension names, but with equations, you do.

Named dimensions make a huge difference when you want to recognize the function of an equation by simply reading it. A most obvious example would be the difference between D3@Sketch6 and Length@WindowExtrusionSketch. The first name means nothing, but the second one is descriptive if you are familiar with the part.

To name a dimension, RMB click the dimension and select Properties. At the top of the dialog box shown in Figure 9.2, type the new name for the dimension in the Name text box. You cannot use the symbol @ in dimension names because it is used as a delimiter between the name of the dimension and the feature or sketch to which it applies.

Renaming a dimension

Figure 9.2. Renaming a dimension

Note

You should keep dimension names as short as possible while still making them unique and descriptive. This is because space in the interface is often limited, and when combined with sketch or feature names (and even part names when used in an assembly), the names can become difficult to read.

Tip

You can show dimension names as a part of the dimension value itself by accessing the setting at Tools, Options, General, Show Dimension Names.

Building the equation

When creating an equation in SolidWorks, it is often a good idea to write it out on paper first. Examine the part shown in Figure 9.3, where the relevant dimensions have been named and displayed. The behavior to be driven by the equations is that the number of holes—called Instances here—is the driving variable. From that number, the spacing of the holes is calculated over the length of the part. There is also a gap on each end of the pattern of holes. This gap (measured between the center of the last hole and the end of the part) needs to always be half of the spacing between the holes. The sigma symbols to the left of the dimensions indicate that an equation is driving it. Dimensions driven by equations cannot be directly edited.

Variables for the hole pattern

Figure 9.3. Variables for the hole pattern

In this case, more sophistication has not been implemented to account for the diameter of the holes possibly interfering with one another when there are a large number of holes. In other words, because there are two values that need to be calculated (the spacing and the gap), you need to create two equations. Because the gap dimension is always half of the spacing, the spacing needs to be calculated first, as follows:

Spacing = Length / ((Instances-1)+1)

The Instances −1 term stands for the number of spacings. If you have two holes, then there is only one spacing. The +1 term stands for the two half-spacings for the two ends. The second equation is simpler and looks like this:

Gap = Spacing / 2

The order of the equations is important. SolidWorks solves the equations in the order in which they are listed in the Equations dialog box. Because the gap is dependent on the spacing, the spacing must be calculated before the gap. If it is done the other way around, then you can get into a situation where it takes two rebuilds to finalize a set of equations, or even a situation where in every rebuild, all of the numbers change. This is called a circular relation, and is a common error in order or history dependent functions, not just in SolidWorks, but in any computer application. Figure 9.4 shows the resulting set of equations.

Equations for the hole pattern

Figure 9.4. Equations for the hole pattern

Before beginning to build the equation, you should first display the dimensions that you need to use to create the equation. You can add dimensions to the equation by clicking them from the graphics window. To do this, RMB click the Annotations folder at the top of the FeatureManager, and select Show Feature Dimensions. You should also select the Display Annotations option if it is not already on. When you have done this, all of the dimensions that you need to create every feature are displayed. Also be sure to turn on Tools

Equations for the hole pattern

Tip

For models that have more than a few features, showing all of the dimensions in the entire model may overload the screen with information. In this case, you can double-click a feature from the FeatureManager to show all of the dimensions on that feature.

To build the equation, first use the Equation button on the Tools toolbar to open the Equations dialog box. Then press the Add button to display the Add Equation dialog box. To add dimensions to the equation section, just click the dimension. You can use the keypad on the dialog box or on your keyboard to add operators and syntax. All standard rules of syntax apply for the order of operations, use of parentheses, and driving versus driven sides of the equation.

Using comments

Notice the comment to the right of the first equation in Figure 9.4. Comments can be very useful for annotating equations for yourself or others. Two important reasons to annotate are to remember the significance of variables or dimensions, and to add special notes about the logic of the equation.

You can make comments for equations by using a single quote after the end of the equation, or by using the Comment button in the Add Equation dialog box. In the following example,

"Spacing@LPattern1" = "Length@Sketch1" / ("Instances@LPattern1") 'This must be solved first

the comment, "This must be solved first," is applied to the equation using the single quote before the comment.

Adding to the earlier discussion about projected changes to the Equation interface, several standard selection functionalities do not work in the Edit Equation dialog box. These include triple-clicking to select all (although double-clicking works to select a single word) and pressing Ctrl+A to select all.

Tip

You can make general comments for the model in the Design Journal, a Microsoft Word document that is embedded into the SolidWorks file. The Design Journal is found in the Design Binder folder near the top of the FeatureManager.

Note

You can find the part used in this section on the CD-ROM with the filename Chapter 9 Equations.sldprt.

Using driven dimensions

Sometimes it is more convenient to use a driven (reference) dimension in an equation. This is particularly true when using geometry is the best way to calculate a number. For example, if you are manufacturing a helical auger in 90-degree sections from flat steel stock, then you need to design the auger in 3D, but begin to manufacture it in 2D.

What is the shape of the auger when flat? The best way to figure this out (aside from lofted bends, which are discussed in Chapter 29) is to use a little high school geometry, a construction sketch, and some simple equations.

Figure 9.5 shows a 90-degree section of an auger blade. The outside diameter is 12 inches, and the blade width is 3 inches. The overall height is 4 inches. In this case, the auger is represented as a surface because the thickness is ignored. Surface features can be useful in situations like this and are discussed in Chapter 27.

Representation of the auger

Figure 9.5. Representation of the auger

Note

You can find the part for Figure 9.5 on the CD-ROM with the filename Chapter 9 Auger.sldprt.

With this information, we can calculate the lengths of the 3D edges using a sketch and a simple equation. In Figure 9.6, the hypotenuses of the triangles represent the helical edges of the helices. By making the triangles the same height as the auger section, and by making the horizontal side of the triangle the same length as a quarter of the inside or outside diameter by using simple equations, the geometry and sketch relations calculate the flat lengths of the inside and outside edges of the auger (length of triangle side = diameter of circle × pi / 4). In this way, the triangle is used to simplify the calculation, and give it a visual result.

Triangles calculate the length of the helical edge.

Figure 9.6. Triangles calculate the length of the helical edge.

From this point, the flat pattern can be calculated again, using SolidWorks' sketch-solving capabilities as the calculator. Think of the auger as being the cardboard tube inside a roll of paper towels. If you examine one of these tubes closely, you see that it is simply a straight and flat strip of cardboard that has been wound around a cylinder. What was the flat, straight edge of the original board is wound into a helix. This method is simply reversing that process.

This example requires the little-used arc-length dimension to drive the size of the arc. The hypotenuse dimensions are shown by driven or reference dimensions, and these are used to drive the arc-length dimensions, as shown in Figure 9.7. Remember that you can create arc length dimensions by using the Smart Dimension tool to click both endpoints of the arc and then the arc itself. Arcs driven by arc length dimensions often do not react to changes predictably, since the radius and center or end point locations are not necessarily defined.

The reasoning behind this example may be a little difficult to grasp, but the equations and the sketches are certainly simple.

Warning

Using reference dimensions on the driving (independent, or right) side of the equation can in some situations require more than one rebuild to arrive at a stable value (meaning a value that does not change with the next rebuild). SolidWorks issues a warning when it sees that you are using a reference dimension in an equation, but it does allow it.

Triangles calculate the length of the helical edge.
Figuring the flat pattern of the auger

Figure 9.7. Figuring the flat pattern of the auger

Equation tricks

Some functions that are allowed in SolidWorks equations are often viewed as parlor tricks, but they actually do have some practical applications. The two functions that fall into this category are IIF and SWITCH. If you are familiar with a programming language, you may already be familiar with these two functions. If not, then they are described below.

IIF

In words, this is how an IIF statement is used:

If some relationship is fulfilled, then the IIF function returns a value. If the relationship is not fulfilled, then it returns a different value.

A more technical description is

IIF(expression, value if true, value if false)

In practice, you could use it like this:

IIF(x>5, x-1, x+1)

which reads, "if x is greater than 5, then subtract 1 from x; if not, then add 1 to x." One of the reasons why this is considered a parlor trick is that this function causes the value of x to oscillate between two numbers (depending on the number that it starts with) with each rebuild. It may be difficult to imagine an application where this sort of behavior would be desirable, but when you combine it with a macro that simply rebuilds a model a number of times, you can use it to create a certain animation effect.

Note

A simple example of the IIF function can be found on the CD-ROM with the filename Chapter 9 Oscillate.sldprt. The equation is shown in Figure 9.8.

An equation using IIF

Figure 9.8. An equation using IIF

Tip

You can find some great examples of this function at www.mikejwilson.com, along with many other extremely creative examples of SolidWorks modeling. The model on this site called Ship in a Bottle.sldprt also includes a macro that will rebuild the model a certain number of times, which is useful for animations that are created in this way.

SWITCH

The SWITCH function enables you to have a list of relationships with associated values. The value of the first relationship in the list that is satisfied is returned by the SWITCH function. For example,

switch (x>2, 1.5, x>1, .5 x<1, 2.5)

reads as follows: "if x is greater than 2, then the answer is 1.5; if x is not greater than 2 but greater than 1, then the answer is .5; if x is not greater than 1 but less than 1, then the answer is 2.5."

As you can see, this function does not cover all situations, but it does create a condition where the value cycles through three different numbers in a specific order. Is this useful? Possibly. Again, the main application for this function would be a simple animation for changing the size or shape of SolidWorks components that cannot be done in other more conventional ways.

Using Link Values

Link values are simply a way to link several dimensions together. A link value is not exactly like an equation that sets the dimensions equal, because it does not depend on order like an equation does. All dimensions are set to the same value simultaneously.

Link values are available by RMB clicking the dimension. Unfortunately, they are not available from the RMB menu when the dimension tool is active. To apply a link value to a new dimension, you must place the dimension, exit the dimension tool, RMB click the dimension, and select Link Value.

Link values are listed under the Equations folder in the FeatureManager. Figure 9.9 shows the link values in a listed part, and the drop-down list from which you can select them or type them. Notice again that the Link Values feature also operates from a dialog box instead of the PropertyManager. I would predict that the Link Values and Equations would be redesigned to function more in sync with one another in a future version of SolidWorks.

Link values listed in the FeatureManager, and the Shared Values interface

Figure 9.9. Link values listed in the FeatureManager, and the Shared Values interface

The first link value that is assigned in a part must be manually typed in. After you add the first one, you can link other dimensions to this link value by using the scroll arrows shown in Figure 9.9. You cannot edit link values. In order to change the value to which a dimension is linked, you must first unlink the value and then relink it. The Unlink function is available from the RMB menu in the same way that you assign link values. Dimensions that have a link value have the small chain symbol displayed to the left of the dimension.

Tip

There is one link value name that has a special significance. If you use the name thickness, then a Link To Thickness option appears in all extrude dialog boxes. This is intended to reflect sheet metal functionality, but it is useful for models of various manufacturing techniques.

To take this one step further, you can save a part template with a thickness link value; all of your new parts will also have this functionality right from the start. To save the template with a link value, you must create at least one dimension to assign the link value, and then delete the geometry (and the dimension); however, the link value will remain.

Link values of different types are not necessarily interchangeable. You cannot use angular dimension link values on radius, diameter, or linear dimensions. You can use linear and diameter link values interchangeably, but not angle link values.

Using Global Variables

Global variables are assigned in the Equations dialog box as simply the variable name equaling the value. Figure 9.10 shows a list of equations, link values, and global variables. When you are typing in the name of the variable, you do not need to add the quotation marks; they are added automatically.

Equations, link values, and global variables

Figure 9.10. Equations, link values, and global variables

Despite the word variable in the name global variable, the values are not variable. They are fixed, and only changeable through the Equations dialog box. The only place where you can use global variables is in equations. You cannot directly enter them into dialog boxes for dimension values.

Using Expressions

Expressions, unlike all of the previous variables, values, and equations, can be entered directly into dimension dialog 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 above, the plus symbol is understood.

Other types of operations are also available, such as 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.

Tutorial: Using Equations

Follow these steps to get some practice with using equations:

  1. Start from the part on the CD-ROM with the filename Chapter9 Tutorial Start.sldprt.

  2. Show the dimension names. This setting is found at Tools

    Tutorial: Using Equations
  3. Double-click the Circular Pattern feature to display the angle and number of instances of the feet and related features. You may have to move the angle dimension to see the pattern instance number.

  4. RMB click the instance number, and select Properties. Change the name of the dimension to # (pound or number sign).

  5. Double-click the first feature, which is the revolve, and rename the 3.60-inch dimension to CapRad.

  6. Write an equation that drives the number of legs by CapRad/7.

    1. Open the Equations dialog box at Tools

      Tutorial: Using Equations
    2. Click Add to add an equation.

    3. Double-click the Circular Pattern and click the # dimension. Make sure that the name of the dimension is listed in the equation box, and type an equal sign.

    4. Double-click the Revolve feature and select the CapRad dimension; then type the characters /7.

    5. Add a comment to the equation to reflect which dimension is driving which dimension.

  7. Click Rebuild, press Ctrl+B or Ctrl+Q to rebuild the model, and observe whether any update takes place.

  8. Rename the 6.00-inch dimension for the height of the revolved feature to DomeHt.

  9. Create a second equation that drives the DomeHt dimension at the current ratio of the height to the radius.

    1. Create a global variable called Ratio = 6/3.6 (1.66667) in the Equations dialog box.

    2. Create the equation. The equation will take the form of DomeHt = (Ratio) × CapRad.

  10. Use a link value to make the radii of Fillet1 and Fillet2 the same.

  11. Double-click Extrude2. Change the .75-inch dimension to .05+20mm (.79'').

  12. Save and close the part with a new name, including your initials or the date.

Summary

SolidWorks equations and related dimension-management tools are powerful, but often leave you wishing for a little more flexibility and control. The interface is not up-to-date with the rest of the SolidWorks interface, and so I would look to see an updated equation interface soon that integrates dimension input, link values, and global variables.

If you want to encourage SolidWorks to revise certain features, then you can go to the SolidWorks Web site and submit an enhancement request. They do look at customer input when developing or updating functionality.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset