using equations in sw 1
TRANSCRIPT
8/10/2019 Using Equations in SW 1
http://slidepdf.com/reader/full/using-equations-in-sw-1 1/12
Using Parametric Equations in SolidWorks, Example 1(Draft 3, 5/15/2006, SW 2006)
Introduction
In this example the goal is to place a soli roller on a soli !ege" #heir relationship !ill $e go%erne $& parametric e'ations sing a esign parameter" In aition to the po!er that SoliWors incles
in its e'ation constrction !ino! for mathematical operations &o !ill see that se%eral *isal +asic
for pplications (*+) options can $e in%oe for aitional logical an mathematical operations"#he esire final reslt, in one configration, is seen in -igre 1"
Figure 1 A desired design configuration under parametric control
#here are at least t!o !a&s to introce a set of parametric esign e'ations into a SoliWors part orconfigration" -irst, a techni'e for introcing glo$al esign %aria$les $efore &o start partconstrction !ill $e illstrate" #hen the follo!ing section !ill sho! ho! to introce them if &o
alrea& ha%e a part ner constrction" s sal, &o mst open a part $efore most of the Tools
options $ecome a%aila$le" #herefore, start the parametric esign process there.
1" Select Tools Equations to open an Equations panel"
2" #he empt& Equations – partname panel appears an &o pic Add to start the e'ations
poplation process $& opening an Add Equation panel"
3" #he Add Equation panel opens $& ispla&ing its fll set of mathematical functions, as !ell asits calculator, !hich incles pi ()" If &o o not !ish to pic those featres !ith the crsor
&o can minimie the panel $& selecting the collapse icon, "" Type the esire e'ation !ith the format of variable = math_function ‘ description ! "
"ote that the a$o%e mathfnction offers mch more po!er that the panel alone sggests
$ecase it can incle *+ mathematics as !ell as #$A logical operations" In this example
&o start !ith a single %aria$le name. 4ength 100 7lo$al parametric esign length8, asillstrate in -igre 2" #o reference this %aria$le name in later e'ations, on the right han sie
of the 8, &o mst incle the name in a pair of 'otes, e"g" 4ength8"
9age 1 of 12
:op&right ;"<" in" ll rights reser%e"
8/10/2019 Using Equations in SW 1
http://slidepdf.com/reader/full/using-equations-in-sw-1 2/12
Figure % &tarting the parametric design variable first
5" #his e'ation then appears in the prior Equations panel as acti%e e'ation nm$er 1, as seen
in the top of -igre 3" SoliWors has also atomaticall& ae 'otes aron the %aria$lename (so &o can later se it on the right han sie of a later e'ation)" #he e'ation can $e
elete or eite in that panel $& selecting the corresponing ta$" =o !ol select Add to
contine the e'ation poplation process" ssme &o plan for a secon glo$al %aria$le $&repeating the a$o%e procere an t&pe in a efinition of the roller iameter as.
>ollerDia 1 ?ptional rollre parameter"
6" If &o fail to notice a t&ping error a$o%e &o simpl& correct it later $& highlighting the secone'ation an select Edit in the Equations panel to place the e'ation in the Edit Equation
panel !here the re'ire changes are mae an accepte (see $ottom of -igre 3)"
@" E'it the Equations panel an (ebuild the part to activate &or e'ations" If &o !ant tosppress (or nsppress) an e'ation simpl& change the checA$ox stats in front of the
e'ation nm$er"
In this iscssion, the term glo$al %aria$le8 might mean glo$al for this configration onl&, or alsoglo$al in other specific esign configrations" -igre sho!s the a$o%e t!o e'ations in the
Equations panel" In that panel &o can pic the )onfigs ta$ to efine the scope of &or esign
%aria$les" #he captions for the three possi$le scope choices are self explanator&"
9age 2 of 12
:op&right ;"<" in" ll rights reser%e"
8/10/2019 Using Equations in SW 1
http://slidepdf.com/reader/full/using-equations-in-sw-1 3/12
Figure * The second design variable
Figure + )onfigurations governed by these t,o variables
=o col contine to a e'ations in a similar !a&" Instea, the follo!ing section !ill sho! ho! to
create e'ations as &o $il a part (or a them to an existing part)"
Constructing the parametric triangular configurations
#he constrction !ill $e 'ite simple geometricall&" ?pen a ne! part" -rom the front plane origin
constrct the horiontal an %ertical lines an then close the triangle" Bost esigns !ill $e parametric
an are efine $& one or more glo$al %aria$les8" #his esign !ill $e go%erne $& t!o esign parametersC glo$al %aria$les ngle8, an 4ength8" #he process re'ires that &o $e a$le to select
an name %arios imensions" #o o that in an& ra!ing &o !ill nee to sho! the featre
imensions, along !ith their names" <ach line (or extrsion thicness, etc") is gi%en a efaltimension name an %ale !hen it is create" ll imensions an names !ill appear in each %ie!"
#hat can reslt in a %er& clttere image !hen a part has man& featres" =o can right clic on
n!ante items an select hie8 to ncltter the ispla&" +etter still, !ol $e to hie each featre
9age 3 of 12
:op&right ;"<" in" ll rights reser%e"
8/10/2019 Using Equations in SW 1
http://slidepdf.com/reader/full/using-equations-in-sw-1 4/12
imension an name after the& are create, if &o no! the& !ill not $e change $& the parametric
esign %aria$les" #&picall&, fillets !ol $e sch a featre"
+egin the part constrction $& trning on the option to ispla& names.
1- Select Tools ptions &ystem ptions &ho, dimension names !
%- In the Feature .anager right clic on Annotations &ho, Feature /imensions"
*- Setching in the front plane, dra, a horiontal line from the origin to ser%e as the $ase of thetriangle" se &mart /imensions to sho! the length &o re! an the efalt name that SW
has assigne to that imension"
+- /ouble clic0 on that imension so that the .odify panel opens, as seen in -igre 5" >ather
than change the nm$er, clic on the o!n arro! for a%aila$le options"
- Select Add Equation" Since there are crrentl& no e'ations efine SW Emps to the Add
Equation panel of the <'ations panel" #he efalt name (in 'otes) of the selecte
imension atomaticall& appears, to start the e'ation"
2- Type in the imension length of 133 (D1FSetch18 100), or tilie the calculator pad4
! " Gotice, in -igre 6, that the efalt imension name (D1) is follo!e $& an F8,follo!e $& the efalt setch name" ?ther neee names can $e appene $& SW to that
crrent string"
Figure /efining the line length ,ith an equation
Figure 2 &etting a dimension ,ith an equation
=o col %ie! the a$o%e steps as an inirect !a& to insert glo$al esign %aria$les" #o o that.
9age of 12
:op&right ;"<" in" ll rights reser%e"
8/10/2019 Using Equations in SW 1
http://slidepdf.com/reader/full/using-equations-in-sw-1 5/12
1" In the Equations panel Edit All (see -igre 6) to open an eit panel"
2" In Edit Equation t&pe 4ength 100 7lo$al %aria$le, ! " #his maes the ne! e'ationappear in the Equations panel" It is place at the top of the list since it oes not reference an&
names on the right of 8" Select Edit All again"
3" In Edit Equations highlight the pre%ios length (100) an replace it !ith 4ength (-igre @)"
Figure 5 /efining and citing a global variable
#hese t!o e'ations ha%e not $een acti%ate &et ($& a >e$il)" +efore oing that the setch !ill $erename (to rece the length of the e'ation), an the imension !ill $e rename to enhance clarit&
of the e'ation.
1" se a slow double clic0 on the name Setch1H in the Feature .anager to replace the efaltsetch name !ith S1H or S1H" ?f corse, if that setch ha a %er& important fnction &o
might se a name longer than the original"2" ?ne !a& to change the imension name is to right clic in the graphics area an pic
6roperties (!hile the imension is highlighte) to open the /imension 6roperties panel"3" #here type the esire name, sa& 7ori8ontal! , as seen in -igre
Figure 9 )hanging the default name property of a dimension
While the name changes ha%e taen effect, as seen in -igre J, the e'ations ha%e not since a >e$ilcomman has not $een isse" #hat is clear since the initial line length is nchange as also seen in
-igre J, an $ecase it oes not ha%e a preceing e'ation s&m$ol, " Go! &o isse a (ebuild
comman to acti%ate the t!o e'ations"
9age 5 of 12
:op&right ;"<" in" ll rights reser%e"
8/10/2019 Using Equations in SW 1
http://slidepdf.com/reader/full/using-equations-in-sw-1 6/12
Figure : Active name changes but inactive equations
Gext the %ertical sie of the triangle !ill ha%e its imension gi%en a name, *ertical, as otline a$o%e,
an !ill ha%e the imensions %ale etermine $& a logical *+ e'ation.1" Dra! the %ertical sie from the origin an close the triangle"
2" -or the %ertical sie &mart /imensions .odify Add Equation (see -igre 10")
Figure 13 &elect an equation to define a dimension
3" #he Add Equation panel appears !ith (the efalt prompt) ;/1<&_1 ="
" Insert a #$A iif statement to create an ifAthenAelse nmerical reslt, sch as t&ping in
;/1<&_1 = >>F ?@ength 1334 34 13B, setting the %ertical imension to 50 or 150 mm"5" Gext, change the efalt name from D1 to *ertical $& sing the /imension 6roperties panel,
as escri$e a$o%e (an in -igre )" #he last t!o steps are seen in -igre 11"
Figure 11 Csing a #$A statement in a &olidDor0s equation
gain, this ne! e'ation !ill not tae effect ntil a (ebuild comman is isse" +efore going on to
that step it !ill $e sefl to re%ie! some of the *+ enhancements an limitations relate to e'ationsin SoliWors"
9age 6 of 12
:op&right ;"<" in" ll rights reser%e"
8/10/2019 Using Equations in SW 1
http://slidepdf.com/reader/full/using-equations-in-sw-1 7/12
Using VBA in SolidWorks equations
While the stanar SW Add Equation panel offers a lot of po!er, it crrentl& has some importantlimitations" ?ne is that the e'ation mst occp& a single line (of nno!n maximm length)"
nother is that it omits a fe! sefl mathematical operations" -inall&, the a%aila$ilit& of logical
fnctions seems to $e missing an is onl& mentione in three lines of the online help" *isal +asic forpplications can help !ith all three shortcomings" #he *+ iif fnction, no!n as the immeiate if, is
a conense one line %ersion of an ifAthenAelse logic !ith s&ntax. iif ( logical_expression,
result_if_true, result_if_false ). -igre 12 sho!s six ifferent ses of iif , an se%en mathematicalfnctions that spplement those liste in SW" #he !oring logical operators in -igre 12 are not 'ite
!hat &o !ol expect if &o are familiar !ith *+ or engineering programming langages lie
-ortran J5" -or logical operators that srprisingl& fail in SW are gi%en in -igre 13"
Figure 1% #$A logic and e'tra functions available for equations
?ne sefl ne! mathematical operation, in -igre 12, is integer arithmetic i%ision !hich is enote
!ith the $acslash (K)" If &o no! *+ e'ation s&ntax &o can al!a&s tr& it in an e'ation" If it isnot tilie in SW &o !ill simpl& get #he s&ntax of this e'ation is incorrect8 as an error message"
L#he athor $elie%es that the SW e'ation parser has a logic error that allo!s onl& one 8 per
statement nlie *+, :, -ortran, ;a%a, etc" #hat !ol clearl& explain the logic failres in -igre 13 an the nee for lie8 in -igre 12"M
9age @ of 12
:op&right ;"<" in" ll rights reser%e"
8/10/2019 Using Equations in SW 1
http://slidepdf.com/reader/full/using-equations-in-sw-1 8/12
Figure 1* Cne'pected #$A logic failures-
Secondary variales
Sometimes &o ma& !ant to calclate items alrea& a%aila$le in SW so to ha%e them han& in an
e'ation an to a%oi tr&ing to incle men pics" Sch items might incle the area, perimeter,
centroi, etc" Nere the first t!o are se to illstrate com$ining name imensions an the s'are rootfnction (s'r)" #he area calclation (!ith incorrect nits ispla&) is gi%en in -igre 1 (after an eit,
not sho!n here, rece the result_if_false from 150 to 15 mm)" #hat figre ser%es as a reminer that
the ser mst assre e%er& term in an e'ation has the same nits" If the nits ispla&e incorrectl&
&o col note that in the comment"
Figure 1+ Adding an area calculation as Equation +
!odi"ying controlling design variales
#he moification of the $ase length glo$al esign parameter !ill $e illstrate next (finall&) to sho!the effect of the $ase length logic on the part height.
1" If the Equations panel is still open simpl& highlight the first e'ation (-igre 15)"
2" ?ther!ise se Feature .anager Equations Edit to open the Equation panel"
3" In the Edit Equation panel change the %ale of 4ength from 100 to 6 mm, ?O"" cti%ate the moifie e'ations !ith a (ebuild"
5" #hat reslts in the height $ecoming 15 mm, as seen in -igre 16
In -igre 16 notice that the height imension is no! precee $& the e'ation s&m$ol to remin &o
that it is go%erne $& an e'ation" #he perimeter calclation also appears in that figre"
9age of 12
:op&right ;"<" in" ll rights reser%e"
8/10/2019 Using Equations in SW 1
http://slidepdf.com/reader/full/using-equations-in-sw-1 9/12
Figure 1 )hanging the base design parameter
Figure 12 6arametric change in the triangle height
Gext, the roller is to $e place tangent to the incline" #he actal position !ill $e set $& the angle from
the origin to the center of the roller" #hat angle, name Angle8, !ill $e etermine $& a logicaloperation (-igre 1@)"
Figure 15 &etting the roller angle via logic
When the eiting of these six e'ations is complete, as seen in -igre 1, there are for possi$le sies
for this pair of o$Eects" #he ata an image for 4ength 6 appear in the top an left center regions of
9age J of 12
:op&right ;"<" in" ll rights reser%e"
8/10/2019 Using Equations in SW 1
http://slidepdf.com/reader/full/using-equations-in-sw-1 10/12
-igre 1" #he corresponing image an ata for 4ength 62 are seen in the mile right an $ottom
regions, respecti%el& of the same figre"
Figure 19 T,o configurations based on the ;@ength global variable
#riven dimensions
It is still possi$le to se ri%en imensions in a part go%erne $& e'ations" -or example, assme &o
nee the center location of the roller" If &o a a %ertical imension to that point the setch trns re
an &o get a !arning that the re'este information shol $e consiere as a ri%en imension"greeing to that change allo!s the imension to appear, $t in a ifferent color (gra& here)" #hose
interactions are illstrate in -igre 1J" <xtring the t!o regions !ith ifferent thicnesses gi%es the
solis seen originall& in -igre 1"
9age 10 of 12
:op&right ;"<" in" ll rights reser%e"
8/10/2019 Using Equations in SW 1
http://slidepdf.com/reader/full/using-equations-in-sw-1 11/12
Closure
:learl&, some of the logic in%oe in this example is not %er& practical an !as chosen Est to illstratethe a$ilit& to se logic in the esign process" #he reaer is encorage to simpl& tr& generating %arios
forms of e'ations, as in -igre 12 an -igre 13, to %erif& that &o nerstan the process" -or
example, tr& incling the *+ line contination s&m$ol, 8 ($lan nerscore), to se a secon linein an e'ation
"
Figure 1: (elated driven dimension to roller center
References
1" #rixial Design an nal&sis, 8ing 4ogic to <'ations. No! *+ can $e tilie to o
amaing things8, SW #ips P #rics, %" A0@, ;l& 200"
2" #rixial Design an nal&sis, 84ins, <'ations, an Design #a$les8, SW #ips P #rics, %" 2A
02, pril 2000"
9age 11 of 12
:op&right ;"<" in" ll rights reser%e"
8/10/2019 Using Equations in SW 1
http://slidepdf.com/reader/full/using-equations-in-sw-1 12/12
3" W"<" No!ar, ;":" Bsto, se of 9arametric Boeling #echni'es8, in Introduction to Solid
Modeling Using SolidWorks, Bc7ra! Nill, 2006"
" B" Spens, Automating SolidWorks 2! using Macros, SD: 9$lications, 200"
5" SD>:, "xploring I#"AS #esign, $. II , Strctral D&namics >esearch :orp", 1JJ6"
9age 12 of 12
:op&right ;"<" in" ll rights reser%e"