Using Equations in SolidWorks

In this exercise we're going to create a plate with equally spaced holes controlled by a parameter file.

You can change the width of the plate and/or the number of holes, and the hole pattern will automatically adjust.

  1. Using NotePad, create a file containing the following:
    "Plate width" = 5in
    "Plate height" = 3in
    "Num holes" = 4
  2. Do not put a space before the "in".
  3. Save the file with the name params.txt

  4. Start SolidWorks.
  5. Turn off the Simulation add-in.
  6. Create a new part.
  7. Turn off Instand3D mode if it's on.
  8. Click on Tools -> Equations
  9. Click on the Import button and import params.txt
  10. Notice that the variables are to be imported as "linked to file".
  11. Click Import in the pop-up window to confirm.
  12. Notice that three new global variables have been defined.
  13. Click OK to exit the Equations dialog.
  14. Note that a new Equations item has appeared in the feature manager tree.

  15. Create an Extruded Base feature on the Front plane.
  16. Draw a rectangle with arbitrary width and height.
  17. Click on View -> Hide/Show -> Dimension Names.
  18. Use the Smart Dimension tool to create a dimension for the width of the rectangle.
  19. In the dimension pop-up dialog, type and "=" sign, then select [Global Variables] and "Plate width". Hit Enter to confirm.
  20. We're going to use a different tecchnique to dimension the height, so you can see both.
  21. Dimension the height of the rectangle and just accept whatever numeric value is shown.
  22. Click OK to accept the sketch.
  23. Set the extrusion depth to 1/8 inch.
  24. Click OK to complete the extrude.

  25. Go back and edit the sketch again.
  26. Right click on Equations in the feature manager tree.
  27. Select Manage Equations.
  28. Click on the Equation View button.
  29. In the Equations section, click on the "Add equation" box.
  30. Click on the D2@Sketch1 dimension, which controls the height.
  31. In the Value/Equation box, which now contains an "=" sign, select:
    = [Global Variables] "Plate height" [Enter]
  32. Click OK to exit the Equation manager.

  33. Click on the Hole Wizard.
  34. Select regular "Hole", ANSI Inch, Screw Clearances, size #4, "Close fit", "Through All".
  35. Switch to the Positions tab and select the face of the plate.
  36. Put one hole near the bottom left corner of the plate.
  37. Select the Smart Dimension tool.
  38. Add a horizontal dimension from the hole to the left edge. This is D1.
  39. Add a vertical dimension from the hole to the bottom edge. This is D2.
  40. Click OK to exit the Hole Wizard.
  41. Open the #4 Clearance Hole feature in the feature manager tree.
  42. Edit the first sketch in that feature.
  43. Right click on Equations in the feature manager tree; select Manage Equations.
  44. Change the value of D2 in the sketch to:
    = [Global Variables] "Plate height" / 3 [Enter]
  45. Change the value of D1 in the sketch to:
    = [Global Variables] "Plate width" / ( [Global Variables] "Num holes" * 2) [Enter]
  46. Click OK to exit the sketch.

  47. Create a Linear Pattern feature.
  48. For Direction1, click on the bottom edge of the plate.
  49. For the distance D1, enter 1in
  50. For number of copies, enter 3.
  51. For Features to Pattern, select the Clearance Hole feature.
  52. Click OK to complete the pattern.

  53. In the feature manager tree, right click on Equations again and select Manage Equations.
  54. Switch to the Dimension View.
  55. Set the value of D3@LPattern1 to:
    = [Global Variables] "Plate width" / [Global Variables] "Num holes"
  56. Set the value of D1@LPattern1 to:
    = "Num holes"
  57. Click OK.
  58. Notice that the plate has four evenly-spaced holes.
  59. In NotePad, change the number of holes from 4 to 5, and resave the file.
  60. Click on the Rebuild button and watch the number of holes change.

  61. In NotePad, change the width from 5 to 6 inches, and resave the file.
  62. Click on the Rebuild button and watch the part change.

  63. Go back into the Equation Manager and observe the four display modes:

Equation Dialog Box: Four Views

  • Equation View - shows global variables and the global equations you've defined.
  • Sketch Equation View - shows only the sketch equations you've defined. Using a sketch equation allows you to click and drag inside a sketch and values will be dynamically recalculated.
  • Dimension View - shows every dimension in the part.
  • Ordered View - shows order of evaluation for equations.

CONDITIONAL FEATURES

  1. We're going to make a large hole that is present only when "Num holes" is odd.
  2. Using the Hole Wizard, create a new Clearance Hole feature.
  3. Set the hole size to #10.
  4. Click on the Positions tab, then click on the front face of the part.
  5. Draw a vertical centerline through the midline of the part.
  6. Place a point on this centerline, about 2/3 of the way up from the bottom.
  7. Add a vertical dimension between the point and the bottom edge.
  8. With the sketch still open, open the Equations manager.
  9. In the Equations section, click in the "Add equation" box.
  10. Click on the vertical dimension you just created.
  11. In the Value box, type the following:
    = [Global variables] "Plate height" * (2/3) [Enter]
  12. Click OK to exit the Equation Manager.
  13. Click OK again to complete the Clearance Hole feature.

  14. Open the Equation Manager again.
  15. In the Features section, click in the "Add feature suppression" box.
  16. Click on the Clearance Hole feature you just created.
  17. In the Value box, type the following:
    = if( ([Global variables] "Num holes" / 2) =
          int([Global variables] "Num holes" / 2), "suppressed", "unsuppressed")
  18. Click OK to exit the equation manager.

  19. In Notepad, change the number of holes to 4 and resave the file.
  20. Click on the Rebuild button in SolidWorks.
  21. Notice that the second Clearance Hole feature is suppressed.

  22. Change the number of holes to 7 in Notepad and resave the file.
  23. Click Rebuild in SolidWorks.

SKETCH EQUATION VIEW

Sketch equations are tied to a specific sketch, and will update the sketch as soon as a dimension changes. Regular equations will not update the sketch until you exit the sketch; they are appropriate when referencing global variables instead of sketch dimensions.

  1. Create a new part.
  2. Click on View -> Hide/Show -> Dimension Names.
  3. Make an extruded base on the front plane.
  4. Draw a rectangle not tied to the origin.
  5. Dimension the width and height of the rectangle.
  6. Draw an ellipse oriented diagonally from bottom left to upper right in the center of the rectangle.
  7. Right click on the bottom line of the rectangle and choose Select Midpoint.
  8. Shift click on the center of the ellipse and add a Vertical property.
  9. Right click on the left line of the rectangle and choose Select Midpoint.
  10. Shift click on the center of the ellipse and add a Horizontal property.
  11. Add a dimension between the top and bottom control points of the ellipse.
  12. Add a dimension between the left and right control points of the ellipse.
  13. Click to accept the sketch and set the extrusion depth to 1/8 inch.

  14. Go back and edit the sketch again.
  15. Enter the Equation Manager and switch to the Sketch Equation view.
  16. Click in the "Add equations" box, then click on the dimension for the vertical extent of the ellipse.
  17. In the Value/Equation box, click on the dimension for the height of the rectangle and then type "* (3/4)" and hit Enter.
  18. Repeat the process to dimension the width of the ellipse to 1/5 the width of the rectangle.
  19. Click OK to exit the Equation Manager.

  20. Edit the sketch again.
  21. Double click on the dimension for the height of the rectangle.
  22. Change the height. You can use the spin wheel instead of typing a number.
  23. Click OK to accept the dimension, and note that the ellipse changes.
  24. Switch to the Other tab in the dimension dialog box.
  25. Check the "Driven" box in the other tab.
  26. Use the same steps to make the dimension for the width of the rectangle "Driven".
  27. Right click on the bottom left corner of the rectangle and click on the anchor icon to fix the point.
  28. Click and drag on the top right corner to change the shape of the rectangle and note that the ellipse also changes shape.
  29. Click and drag on any ellipse control point and note that the rectangle changes shape.
  30. The only way to undo the "Fixed" attribute of the bottom left point is to click on it and then click on "Fixed" in the property manager and press Delete.

  31. Bring up the Equation Manager and notice the warning messages about potential circularity.
  32. To eliminate the circularity warnings, remove the "Driven" attribute from the dimensions. It's also okay to just ignore the warnings.

CONFIGURATION MANAGER

  1. Click on the Configuration Manager button in the left window.
  2. Right click on the part and select "Add Configuration".
  3. Name the new configuration "signed".
  4. Click OK to exit the Configuration Manager.
  5. Click on the Feature manager button in the left window.
  6. Notice that the part is shown in the "signed" configuration.

  7. Create an Extruded Cut feature on the part face.
  8. In the sketch, add a text element.
  9. Type your initials in the text box and click OK.
  10. Move the text element to the top left corner of the part.
  11. Click OK and select "All bodies" if asked.
  12. Set the Extruded Cut parameter to "Through All"
  13. Click OK to complete the feature.
  14. Return to the Configuration Manager and double click on the "Default" configuration.
  15. Return to the Feature Manager.
    • Notice that the Extruded Cut feature is now suppressed.

DESIGN TABLES

Design tables allow you to conveniently represent multiple configurations of a part in an easily readable tabular form. They also offer a more powerful equation mechanism since Excel formulas can do more than SolidWorks equations, e.g., they can do table lookup operations, pulling data from other tabs in the spreadsheet.

  1. Make a new part.
  2. Make an extruded base on the front plane.
  3. Draw a rectangle.
  4. Dimension the rectangle and name the dimensions Height and Width.
  5. Extrude it.
  6. Go to Insert > Tables > Excel Design Table. Accept the defaults.
  7. Use control-click to add all dimensions to the table, then click Okay.
  8. Add four new rows for configurations "small square", "small rectangle", "large square", and "large rectangle". Fill in appropriate values.
  9. Adjust the width of column A so the names are readable.
  10. Click outside the spreadsheet to close it.
  11. Go to the Configuration Manager tab and change between the various configurations.

  12. To editor the design file: go to the Configuration Manager tab, open up the Tables folder, right click on Excel Design Table, and select "Edit Table".

  13. Add an extruded cut feature that is a small slot in the bottom left corner of the part.
  14. Dimension the slot.
  15. Reopen the design table by switching to the Configurations tab, opening the "Tables" item, right clicking on "Design Table" and choosing "Edit Table".
  16. Hit "Okay" without selecting anything in the dialog box.
  17. Double click on the Cut-Extrude feature to display its sketch dimensions.
  18. Make sure that the selected cell in the spreadsheet is the first free cell in row 2.
  19. Double click on a dimension in the graphics window to add it to the spreadsheet.
  20. Note that your spreadsheet entries can contain references to other cells and even arbitrary Excel formulas.
  21. It's also possible to export the design table as a regular Excel file.