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.
- Using NotePad, create a file containing the following:
"Plate width" = 5in
"Plate height" = 3in
"Num holes" = 4
- Do not put a space before the "in".
- Save the file with the name params.txt
- Start SolidWorks.
- Turn off the Simulation add-in.
- Create a new part.
- Turn off Instand3D mode if it's on.
- Click on Tools -> Equations
- Click on the Import button and import params.txt
- Notice that the variables are to be imported as "linked to file".
- Click Import in the pop-up window to confirm.
- Notice that three new global variables have been defined.
- Click OK to exit the Equations dialog.
- Note that a new Equations item has appeared in the feature manager tree.
- Create an Extruded Base feature on the Front plane.
- Draw a rectangle with arbitrary width and height.
- Click on View -> Hide/Show -> Dimension Names.
- Use the Smart Dimension tool to create a dimension for the width of the rectangle.
- In the dimension pop-up dialog, type and "=" sign, then select [Global Variables] and "Plate width". Hit Enter to confirm.
- We're going to use a different tecchnique to dimension the height, so you can see both.
- Dimension the height of the rectangle and just accept whatever numeric value is shown.
- Click OK to accept the sketch.
- Set the extrusion depth to 1/8 inch.
- Click OK to complete the extrude.
- Go back and edit the sketch again.
- Right click on Equations in the feature manager tree.
- Select Manage Equations.
- Click on the Equation View button.
- In the Equations section, click on the "Add equation" box.
- Click on the D2@Sketch1 dimension, which controls the height.
- In the Value/Equation box, which now contains an "=" sign, select:
= [Global Variables] "Plate height" [Enter]
- Click OK to exit the Equation manager.
- Click on the Hole Wizard.
- Select regular "Hole", ANSI Inch, Screw Clearances, size #4, "Close fit", "Through All".
- Switch to the Positions tab and select the face of the plate.
- Put one hole near the bottom left corner of the plate.
- Select the Smart Dimension tool.
- Add a horizontal dimension from the hole to the left edge. This is D1.
- Add a vertical dimension from the hole to the bottom edge. This is D2.
- Click OK to exit the Hole Wizard.
- Open the #4 Clearance Hole feature in the feature manager tree.
- Edit the first sketch in that feature.
- Right click on Equations in the feature manager tree; select Manage Equations.
- Change the value of D2 in the sketch to:
= [Global Variables] "Plate height" / 3 [Enter]
- Change the value of D1 in the sketch to:
= [Global Variables] "Plate width" / ( [Global Variables] "Num holes" * 2) [Enter]
- Click OK to exit the sketch.
- Create a Linear Pattern feature.
- For Direction1, click on the bottom edge of the plate.
- For the distance D1, enter 1in
- For number of copies, enter 3.
- For Features to Pattern, select the Clearance Hole feature.
- Click OK to complete the pattern.
- In the feature manager tree, right click on Equations again and select Manage Equations.
- Switch to the Dimension View.
- Set the value of D3@LPattern1 to:
= [Global Variables] "Plate width" / [Global Variables] "Num holes"
- Set the value of D1@LPattern1 to:
= "Num holes"
- Click OK.
- Notice that the plate has four evenly-spaced holes.
- In NotePad, change the number of holes from 4 to 5, and resave the file.
- Click on the Rebuild button and watch the number of holes change.
- In NotePad, change the width from 5 to 6 inches, and resave the file.
- Click on the Rebuild button and watch the part change.
- 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
- We're going to make a large hole that is present only when "Num holes" is odd.
- Using the Hole Wizard, create a new Clearance Hole feature.
- Set the hole size to #10.
- Click on the Positions tab, then click on the front face of the part.
- Draw a vertical centerline through the midline of the part.
- Place a point on this centerline, about 2/3 of the way up from the bottom.
- Add a vertical dimension between the point and the bottom edge.
- With the sketch still open, open the Equations manager.
- In the Equations section, click in the "Add equation" box.
- Click on the vertical dimension you just created.
- In the Value box, type the following:
= [Global variables] "Plate height" * (2/3) [Enter]
- Click OK to exit the Equation Manager.
- Click OK again to complete the Clearance Hole feature.
- Open the Equation Manager again.
- In the Features section, click in the "Add feature suppression" box.
- Click on the Clearance Hole feature you just created.
- In the Value box, type the following:
= if( ([Global variables] "Num holes" / 2) =
int([Global variables] "Num holes" / 2), "suppressed", "unsuppressed")
- Click OK to exit the equation manager.
- In Notepad, change the number of holes to 4 and resave the file.
- Click on the Rebuild button in SolidWorks.
- Notice that the second Clearance Hole feature is suppressed.
- Change the number of holes to 7 in Notepad and resave the file.
- 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.
- Create a new part.
- Click on View -> Hide/Show -> Dimension Names.
- Make an extruded base on the front plane.
- Draw a rectangle not tied to the origin.
- Dimension the width and height of the rectangle.
- Draw an ellipse oriented diagonally from bottom left to upper right in the center of the rectangle.
- Right click on the bottom line of the rectangle and choose Select Midpoint.
- Shift click on the center of the ellipse and add a Vertical property.
- Right click on the left line of the rectangle and choose Select Midpoint.
- Shift click on the center of the ellipse and add a Horizontal property.
- Add a dimension between the top and bottom control points of the ellipse.
- Add a dimension between the left and right control points of the ellipse.
- Click to accept the sketch and set the extrusion depth to 1/8 inch.
- Go back and edit the sketch again.
- Enter the Equation Manager and switch to the Sketch Equation view.
- Click in the "Add equations" box, then click on the dimension for the vertical extent of the ellipse.
- In the Value/Equation box, click on the dimension for the height of the rectangle and then type "* (3/4)" and hit Enter.
- Repeat the process to dimension the width of the ellipse to 1/5 the width of the rectangle.
- Click OK to exit the Equation Manager.
- Edit the sketch again.
- Double click on the dimension for the height of the rectangle.
- Change the height. You can use the spin wheel instead of typing a number.
- Click OK to accept the dimension, and note that the ellipse changes.
- Switch to the Other tab in the dimension dialog box.
- Check the "Driven" box in the other tab.
- Use the same steps to make the dimension for the width of the rectangle "Driven".
- Right click on the bottom left corner of the rectangle and click on the anchor icon to fix the point.
- Click and drag on the top right corner to change the shape of the rectangle and note that the ellipse also changes shape.
- Click and drag on any ellipse control point and note that the rectangle
changes shape.
- 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.
- Bring up the Equation Manager and notice the warning messages about potential circularity.
- To eliminate the circularity warnings, remove the "Driven" attribute
from the dimensions. It's also okay to just ignore the warnings.
CONFIGURATION MANAGER
- Click on the Configuration Manager button in the left window.
- Right click on the part and select "Add Configuration".
- Name the new configuration "signed".
- Click OK to exit the Configuration Manager.
- Click on the Feature manager button in the left window.
- Notice that the part is shown in the "signed" configuration.
- Create an Extruded Cut feature on the part face.
- In the sketch, add a text element.
- Type your initials in the text box and click OK.
- Move the text element to the top left corner of the part.
- Click OK and select "All bodies" if asked.
- Set the Extruded Cut parameter to "Through All"
- Click OK to complete the feature.
- Return to the Configuration Manager and double click on the "Default" configuration.
- 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.
- Make a new part.
- Make an extruded base on the front plane.
- Draw a rectangle.
- Dimension the rectangle and name the dimensions Height and Width.
- Extrude it.
- Go to Insert > Tables > Excel Design Table. Accept the defaults.
- Use control-click to add all dimensions to the table, then click Okay.
- Add four new rows for configurations "small square", "small rectangle", "large square", and "large rectangle". Fill in appropriate values.
- Adjust the width of column A so the names are readable.
- Click outside the spreadsheet to close it.
- Go to the Configuration Manager tab and change between the various configurations.
- 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".
- Add an extruded cut feature that is a small slot in the bottom left corner of the part.
- Dimension the slot.
- Reopen the design table by switching to the Configurations tab, opening the "Tables" item, right clicking on "Design
Table" and choosing "Edit Table".
- Hit "Okay" without selecting anything in the dialog box.
- Double click on the Cut-Extrude feature to display its sketch dimensions.
- Make sure that the selected cell in the spreadsheet is the first free cell in row 2.
- Double click on a dimension in the graphics window to add it to the spreadsheet.
- Note that your spreadsheet entries can contain references to other cells and even arbitrary Excel formulas.
- It's also possible to export the design table as a regular Excel file.
|