Type to search

Global Variables and Equation Driven Design


Global Variables and Equation Driven Design

Designing things on the fly can be fun and intuitive. But as soon as you start changing those features, everything you’ve done up to that point can potentially go right out of the window.

Thankfully, by using SOLIDWORKS’ equation capabilities, it is possible to fully define your sketch and model geometry and establish relationships and constraints through equations. This is particularly useful in engineering, as many systems rely on ratios and dynamic relationships that change depending on specific geometric characteristics.

Say for example, you are designing some kind of fluid nozzle. Maybe you would like your nozzle outlet to have a diameter that changes with regard to a specific inlet diameter or even some value for pressure.

In SOLIDWORKS this is pretty easy. You can even define the value for pressure at the inlet and have the outlet diameter change when you rebuild the model. These features can allow you to evaluate various design options without having to manually redesign your model each time you wish to change a parameter. We won’t go that far in this article. We will just look at designing a basic shower head, and we will link the dimensions to a set of basic equations.

Equations can be used to drive both sketch geometry and model geometry. For both cases, they work in a similar manner. Let’s take a look at how to drive sketch geometry with equations.

Equations, Global Variables and Dimensions

Let’s start by looking at how to input dimensions and equations. First, go to Tools > Equations.

On clicking Equations, you should notice a new window pop up, titled Equations, Global Variables and Dimensions.

This is where most of the equation action will take place. Let’s have a look at this in a little more detail since we will be using it later.

Global Variables

Global Variables can be used to drive equations and dimensions. Say for example, you were designing a pipe and wanted the pipe length to remain relative to some other dimension—maybe your pipe has some length constraints relative to its installation location.

You could name a Global Variable as “PipeLimit.” When you go to create your actual pipe, you can define the pipe length in terms of a fraction of that limit in the equation field. Whenever you make changes to your pipe, it will remain within the allowed boundaries.

If it somehow breaches that boundary, then you can use the Feature section to suppress the pipe if it gets too big.

Tutorial Time!

Everything in SOLIDWORKS begins with a sketch. So, this is where we will begin this tutorial.

First, sketch two concentric circles of diameter 100mm and 90mm.

Now comes an important step. We need to define these dimensions with the Smart Dimension tool so that the Equations functions will recognize them.

With the sketch still open, go to Smart Dimension, click it and click the outer diameter of the circle you just drew. Name it as “Outer.”

Do the same for the inner concentric circle and name it “Inner.”

Now they are defined and named with the Smart Dimension tool. When you go to Tools>Equations and open up the Equations, Global Variables and Dimensions panel (shown below) and click the Dimension View tab (circled below in red), you will see that the Dimensions section has been populated with the Smart Dimensions from the sketch.

OK, let’s open the same sketch back up and draw two more concentric circles inside the other two. Let’s convert these circles to construction geometry—right click on the circle sketch and select the Construction Geometry icon. Don’t worry about the precise diameter. We will have these new diameters driven by our global variable later. Just be sure to use the Smart Dimension tool and rename them as D1 and D2.

Now, sketch two little circles, one on each of the construction circles that we just sketched. Use the Smart Dimension tool and rename them “OuterHole” and “InnerHole.”

Next up, create a Circular Pattern of these new holes. Create four equally spaced instances so we end up with eight holes.

That will do for the sketching. We can now go ahead and extrude the sketch entities.

Firstly, extrude the outer ring—the contour area in between the sketch elements we named as “Inner” and “Outer”—as you can see below. Extrude it to 10mm.

Next, extrude the inner area (the base) ensuring that you don’t accidentally extrude/fill the eight little circles up. Extrude that base area to 3mm. If you’ve followed the steps correctly, then your final solid shape should look like the image below.

The Equations and Global Variables Bit

OK, now we have our solid created from a Smart Dimensioned sketch. All of those dimensions are now visible in the Equations, Global Variables and Dimensions panel. Since they are all visible in that panel, we can now start linking them up and making them a little more dynamic and responsive to our design changes.

This is the part where we transform the solid from a dumb model into a smart model.

Let’s have a recap of what is now visible in the Equations, Global Variables and Dimensions panel now that we have populated it with the Smart Dimensions.

At this point, if we click on any populated field in the Value/Equation column, we can change the value in that field. Our sketch (and solid) will respond to that change. You will notice that not only are the sketch entities in the table, but the boss extrusion feature dimensions also have appeared.

Even though our model is still relatively dumb, you can automatically see the value of having all of your dimensions collected in one place like this. From this panel, we can literally just find a parameter we wish to change and do so, safe in the knowledge that the model will update to reflect those changes on rebuild.

It sure as heck beats opening up different sketches and manually editing them every time we want to make a change.

For example, if I want to change the number of instances in the circular pattern, I simply click the Value/Equation field for the CircularPat@Sketch1 entry and increase or decrease it as I see fit.

In this example, I want to change the number of holes to 12. I change the CircularPat entry to six because we are actually patterning the two original holes, so 2 x 6 = 12. Keep this Circular Pattern thing in your minds. We will be making this into an equation-driven value later.

Let’s start to add the Global Variables. Open up the Equations, Global Variables and Dimensions panel again, and in the Global Variables section, add a new Global Variable named “OuterDiameter” and type the value of “=100mm” in the corresponding Value/Equation cell. Be sure to use the equals symbol (=) when entering values here.

Now create a second Global Variable named “HoleDiameter” and set it to 8mm.

Beneath that, create a new Global Variable named “HoleArea.” Now we can start to use some formulae. We want to define the individual hole area in terms of the diameter so that it’s equal to pi multiplied by the radius squared.

In the HoleArea value cell, we can enter this formula as =PI * (HoleDiameter).

You don’t have to actually type HoleDiameter. You can just click the Global Variable name or select it from the drop-down menu while typing the rest of it.

Now that these Global Variables are added, we can refer to these when defining the dimensions or creating equations. They are now magically stored in the software somewhere and can be recalled when linking to values.

For example, we wish to link our OUTER@Sketch1 value to the OuterDiameterGlobal Variable.

We can do this by simply deleting the original value of 100mm from the OUTER@Sketch1 value field and clicking the cursor in the empty cell. You will see a list appear in a pop-up menu showing various options, including to insert a Global Variable.

In this case, we want to link the OuterDiameterGlobal Variable to the OUTER@Sketch1 dimension. You can see this in the image below.

Now that we have those Global Variables defined, we can use them as a benchmark to create relationships with the other sketch and model entities. We can do this with equations.


Entering equations in SOLIDWORKS is fairly easy. There’s no need for any deep programming knowledge. It’s comparable to entering equations in a spreadsheet.

Imagine that you are designing some sort of fluid system and wish to maintain a specific total area for the holes for the fluid to pass through, and you want that total area to remain constant regardless of the diameter of each individual hole. To put it another way, we want the number of holes to change and maintain a constant total area.

Let’s say we want that area to equal 2,400 square millimeters. This will be our target value. We can treat this as a constant, so we create a new Global Variable called “TOTALholeAREA” and set it to 2,400, as you can see in the image below.

Next, we want our number of holes to change in order to maintain that total area, regardless of the diameter of the holes. We create a final Global Variable called “HolesNeeded” and add a little formula for that.

The number of holes will be equal to the total combined area of all of the holes divided by the individual hole area. Since we want an integer value, we can use the “Round” function to round it off. In the Holes Needed Value/Equation cell, we can use the syntax =ROUND (TOTALholeAREA / HoleArea) to return an integer value. Remember to add the parentheses after the ROUND command to tell the software to perform that function on whatever is inside the brackets, just like your spreadsheet program.

Now we want to have the output of that formula drive one of our dimensions. Specifically, we want to have that output drive the number of instances in the circular pattern.

Following the same procedure from before, where we assigned Global Variable values to dimensions, we simply click the adjacent cell to the CircularPat@Sketch1 dimension and link that to the HolesNeeded variable. We divide that by two, as you can see below.

Why are we dividing it by two? Because we have two sets of holes: one on the outside, and one on the inside.

Now Test!

That’s it. It’s all done.

Now you can go ahead and test it. If you’ve followed the steps correctly, you can change the values for hole diameter in the Global Variable section and the model will update the number of holes needed to maintain a constant area.

It could be useful for designing a shower head, injector system or anything where you might like to maintain a constant flow while varying the number of holes. Of course, there’s a lot more to fluid dynamics than that. You can link all kinds of variables and equations. It’s all down to your ingenuity, and patience.

You can see how our new smart model responds to changes in the video below.