






Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!







(Draft 3, 5/15/2006, SW 2006)
In this example the goal is to place a solid roller on a solid wedge. Their relationship will be governed by parametric equations using a design parameter. In addition to the power that SolidWorks includes in its equation construction window for mathematical operations you will see that several Visual Basic for Applications (VBA) options can be invoked for additional logical and mathematical operations. The desired final result, in one configuration, is seen in Figure 1. Figure 1 A desired design configuration under parametric control There are at least two ways to introduce a set of parametric design equations into a SolidWorks part or configuration. First, a technique for introducing global design variables before you start part construction will be illustrated. Then the following section will show how to introduce them if you already have a part under construction. As usual, you must open a part before most of the Tools options become available. Therefore, start the parametric design process there:
Figure 2 Starting the parametric design variable first
dimension and name after they are created, if you know they will not be changed by the parametric design variables. Typically, fillets would be such a feature. Begin the part construction by turning on the option to display names:
1. Select Tools Options System Options Show dimension names OK 2. In the Feature Manager right click on Annotations Show Feature Dimensions. 3. Sketching in the front plane, draw a horizontal line from the origin to serve as the base of the triangle. Use Smart Dimensions to show the length you drew and the default name that SW has assigned to that dimension. 4. Double click on that dimension so that the Modify panel opens, as seen in Figure 5. Rather than change the number, click on the down arrow for available options. 5. Select Add Equation. Since there are currently no equations defined SW jumps to the Add Equation panel of the Equations panel. The default name (in quotes) of the selected dimension automatically appears, to start the equation. 6. Type in the dimension length of 100 (“D1@Sketch1” = 100), or utilize the calculator pad, OK. Notice, in Figure 6, that the default dimension name (D1) is followed by an “@”, followed by the default sketch name. Other needed names can be appended by SW to that current string. Figure 5 Defining the line length with an equation Figure 6 Setting a dimension with an equation You could view the above steps as an indirect way to insert global design variables. To do that: Page 4 of 12
While the standard SW Add Equation panel offers a lot of power, it currently has some important limitations. One is that the equation must occupy a single line (of unknown maximum length). Another is that it omits a few useful mathematical operations. Finally, the availability of logical functions seems to be missing and is only mentioned in three lines of the online help. Visual Basic for Applications can help with all three shortcomings. The VBA iif function, known as the immediate if, is a condensed one line version of an if-then-else logic with syntax: iif ( logical_expression, result_if_true, result_if_false ). Figure 12 shows six different uses of iif , and seven mathematical functions that supplement those listed in SW. The working logical operators in Figure 12 are not quite what you would expect if you are familiar with VBA or engineering programming languages like Fortran 95. Four logical operators that surprisingly fail in SW are given in Figure 13. Figure 12 VBA logic and extra functions available for equations One useful new mathematical operation, in Figure 12, is integer arithmetic division which is denoted with the backslash (). If you know VBA equation syntax you can always try it in an equation. If it is not utilized in SW you will simply get “The syntax of this equation is incorrect” as an error message. [The author believes that the SW equation parser has a logic error that allows only one “=” per statement unlike VBA, C, Fortran, Java, etc. That would clearly explain the logic failures in Figure 13 and the need for “like” in Figure 12.] Page 7 of 12
Figure 13 Unexpected VBA logic failures.
Sometimes you may want to calculate items already available in SW so to have them handy in an equation and to avoid trying to include menu picks. Such items might include the area, perimeter, centroid, etc. Here the first two are used to illustrate combining named dimensions and the square root function (sqr). The area calculation (with incorrect units display) is given in Figure 14 (after an edit, not shown here, reduced the result_if_false from 150 to 145 mm). That figure serves as a reminder that the user must assure every term in an equation has the same units. If the units displayed incorrectly you could note that in the comment. Figure 14 Adding an area calculation as Equation 4
The modification of the base length global design parameter will be illustrated next (finally) to show the effect of the base length logic on the part height:
Figure 18. The corresponding image and data for Length = 62 are seen in the middle right and bottom regions, respectively of the same figure. Figure 18 Two configurations based on the “Length” global variable
It is still possible to use driven dimensions in a part governed by equations. For example, assume you need the center location of the roller. If you add a vertical dimension to that point the sketch turns red and you get a warning that the requested information should be considered as a driven dimension. Agreeing to that change allows the dimension to appear, but in a different color (gray here). Those interactions are illustrated in Figure 19. Extruding the two regions with different thicknesses gives the solids seen originally in Figure 1. Page 10 of 12
Clearly, some of the logic invoked in this example is not very practical and was chosen just to illustrate the ability to use logic in the design process. The reader is encouraged to simply try generating various forms of equations, as in Figure 12 and Figure 13, to verify that you understand the process. For example, try including the VBA line continuation symbol, “ _” (blank underscore), to use a second line in an equation . Figure 19 Related driven dimension to roller center