Online Book Reader

Home Category

SolidWorks 2011 Parts Bible - Matt Lombard [148]

By Root 820 0
tool to click both endpoints of the arc and then the arc itself.

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

Caution

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.

Equations are listed in the Equations folder in the FeatureManager. You can edit, add, or delete them through the right mouse button (RMB) menu.

FIGURE 10.9

Figuring the flat pattern of the auger

Using equation tricks

Some functions that are permitted 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 any programming language, you may already be familiar with these two functions.

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.

On the DVD

A simple example of the IIF function can be found on the DVD with the filename Chapter 10 Oscillate.sldprt. The equation is shown in Figure 10.10.

FIGURE 10.10

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.

You can use an IIF statement to control the suppression state of features and components. This function is described in detail later in this chapter.

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 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 changed in other more conventional ways.

Using Link Values

Link values are simply a way to link several dimensions together, making them equal. 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.

A special relationship and overlap of functionality exists between Link Values and Global Variables. I cover this relationship in this chapter.

Link values are available by right-clicking on a dimension. You can also get to link values by clicking the down arrow on the right side of the Modify dialog box. Unfortunately,

Return Main Page Previous Page Next Page

®Online Book Reader