You are on page 1of 370

VERSION 11.

0
PART NUMBER
110VIEWAD-01
Visit us at: www.adams.com
Advanced
ADAMS/View Training
Guide
2 Copyright
U.S. Government Restricted Rights: If the Software and Documentation are provided in connection with a
government contract, then they are provided with RESTRICTED RIGHTS. Use, duplication or disclosure is
subject to restrictions stated in paragraph (c)(1)(ii) of the Rights in Technical Data and Computer Software
clause at 252.227-7013. Mechanical Dynamics, Incorporated, 2300 Traverwood Drive, Ann Arbor, Michigan
48105.
The information in this document is furnished for informational use only, may be revised from time to time,
and should not be construed as a commitment by Mechanical Dynamics, Incorporated. Mechanical
Dynamics, Incorporated, assumes no responsibility or liability for any errors or inaccuracies that may
appear in this document.
This document contains proprietary and copyrighted information. Mechanical Dynamics, Incorporated
permits licensees of ADAMS

software products to print out or copy this document or portions thereof


solely for internal use in connection with the licensed software. No part of this document may be copied for
any other purpose or distributed or translated into any other language without the prior written permission of
Mechanical Dynamics, Incorporated.
2001 by Mechanical Dynamics, Incorporated. All rights reserved. Printed in the United States of America.
ADAMS

is a registered United States trademark of Mechanical Dynamics, Incorporated.


All other product names are trademarks of their respective companies.
3
COMTMTS
WeIcome fo Advonced ADAMS/View Troining 7
About Mechanical Dynamics 8
Course Overview 9
Getting Help in Class 10
Getting Help at Your Job Site 11
Infroducfion 13
Virtual Prototyping Process 14
How You Benefit from Using Advanced ADAMS/View 15
Assumptions 16
Workshop 1Introduction 17
|xpressions: Overview 25
Why Use Expressions? 26
Expressions: Compute Values 27
Expressions: Parameterize 28
Syntax: Data Types 30
Syntax: Operands 31
Expression Builder 35
Syntax Pitfalls 36
Workshop 2Expressions: Overview 37
|xpressions: Funcfions 49
Functions Overview 50
Functions: Location 51
Functions: Orientation 52
Functions: Modeling 53
Functions: User-Written 54
Expressions: Saving Your Work 55
Workshop 3Expressions: Functions 56
Poromefrics: Overview 69
Tools for Parametrics 70
Workshop 4Parameterizing an Existing Model 76
4 Contents
COMTMTS,,,
Poromeferi;ing o Mew ModeI 93
Construction Points to Parameterize a New Model 94
Workshop 5Parameterizing a New Model 95
Design Sfudy 107
Design Variables 108
Design Studies Overview 111
Specifying an Objective 113
Execution Display Settings 114
Output Settings 118
Setting Design Variables to Trial Values 119
Plotting 120
Workshop 6Performing a Design Study 121
Design of |xperimenfs 133
Design of Experiments (DOE) Overview 134
Trials Defined By 135
DOE Process in ADAMS/View 139
Workshop 7Design of Experiments 140
Opfimi;ofion 149
Optimization Overview 150
Constraints 151
Optimization Settings 152
Workshop 8Optimization 158
Commond Longuoge 167
General Structure 168
Getting Familiar with Commands 169
Types of Commands 173
Workshop 9Understanding the Command Language 174
CondifionoI Consfrucfs ond Loops 189
FOR/END Loop (Numeric Iteration) 190
FOR/END Loop (Object-Based) 191
WHILE/END 192
If/Then/Else 193
Workshop 10Conditional Constructs and Loops 194
Contents 5
COMTMTS,,,
Mocros: Overview 209
Macro Overview 210
Creating Macros 214
Creating Macros 215
Executing Macros 218
Debugging 219
Workshop 11Macros: Overview 223
Mocros: Synfox ond Poromefers 233
Parameters 234
Workshop 12Macros and Parameter Syntax 241
Menus 263
Menu Builder 264
Syntax of Menu File 265
Using Commands to Add Menus 268
Workshop 13Creating Custom Menu Buttons 269
DioIog 8oxes 287
GUI Overview 288
Terminology 289
Working with Dialog Boxes 290
Working with Dialog Boxes 292
Working with Dialog Boxes 293
Dialog Box Builder Overview 294
Dialog Box Commands 297
Dialog Box Database Storage 298
Workshop 14Working with Dialog Boxes 299
DioIog 8ox 8uiIder 317
Substituting Text into Commands 318
Working with Dialog Box Objects 320
Saving Dialog Boxes 326
Workshop 15Working with the Dialog Box Builder 327
Wrop-up 343
Build Files 344
Workshop 16Wrap-up 345
6 Contents
COMTMTS,,,
Mocros 351
Macro for Workshop 14 352
Answer Key 353
Answer Key for Workshop 1 354
Answer Key for Workshop 2 355
Answer Key for Workshop 3 356
Answer Key for Workshop 4 357
Answer Key for Workshop 5 358
Answer Key for Workshop 6 359
Answer Key for Workshop 7 360
Answer Key for Workshop 8 361
Answer Key for Workshop 9 362
Answer Key for Workshop 10 363
Answer Key for Workshop 11 364
Answer Key for Workshop 13 365
Answer Key for Workshop 14 366
Answer Key for Workshop 15 368
Answer Key for Workshop 16 369
7
WLCOM TO ADVAMCD ADAMS/VIW TRAIMIM9
Welcome to Advanced ADAMS/View training. In this course, you learn how
to parameterize your model to determine how different modeling parameters
influence the design and how to iterate on those to achieve the optimal
design. You will also learn how to build macros and tailor the virtual
prototyping process within ADAMS/View to specific applications.
Whut's in this section:
s About Mechanical Dynamics, 8
s Course Overview, 9
s Getting Help in Class, 10
s Getting Help at Your Job Site, 11
8 Welcome to Advanced ADAMS/View Training
About MechunicuI Dynumics
Find u Iist of ADAMS products ut:
s http://www.adams.com/mdi/product/modules.htm
Leurn ubout the ADAMS-CAD/CAM/CA integrution ut:
s http://www.adams.com/mdi/product/partner.htm
Find udditionuI truining ut:
s http://support.adams.com/training/training.html
s Or your local support center
Welcome to Advanced ADAMS/View Training 9
Course Overview-
Lecture-
Hunds-on workshops-
Ask students why they came and what their expectations are. This will allow them to realign their expec-
tations, if necessary.
State the major topics that will be covered (see Table of Contents).
Same structure and format of 5-day Basic class. Its made up of modules (lecture, workshop, and review
for each one).
10 Welcome to Advanced ADAMS/View Training
9etting HeIp in CIuss
Referencing the onIine guide 8VLQJWKH$'$069LHZ)XQFWLRQ%XLOGHU
Doing gIobuI seurches on uny onIine ADAMS guide-
Demo the search and select text functions in Acrobat Reader:
Search in displayed guide:
Global search:
Select text:
Zoom in:
Zoom out: press Ctrl +
s Show relevant sections of
ADAMS/View guides:
s Refining Models
s Customizing
s Function Builder
Welcome to Advanced ADAMS/View Training 11
9etting HeIp ut Your Job Site
OnIine guides
Access heIp on heIp from:
s Help menu of any ADAMS product
s Help tool on the Documentation Road Map
KnowIedge buse -
Go to http://support.adams.com/kb
For a quick tour, go to: http://
www.adams.com/mdi/news/dyndim/
vol3_kbtour.htm
ASK emuiI-bused users group
Go to http://support.adams.com/support/
tech_ask.html
ConsuIting services
Go to: http://support.adams.com/support/
cnsltsrv.html
TechnicuI support
To find your support center, go to: http://support.adams.com/support/suppcent.html
To read the Service Level Agreement, go to: http://support.adams.com/support/sla_agree.html
Survey class quickly to see who is on ASK and who has used the knowledge base.
12 Welcome to Advanced ADAMS/View Training
Motes
13
J
IMTRODUCTIOM
This module introduces you to where advanced ADAMS/View features fit into
the overall ADAMS virtual prototyping process. It also explains the benefits of
using advanced ADAMS/View features.
Whut's in this moduIe:
s Virtual Prototyping Process, 14
s How You Benefit from Using Advanced ADAMS/View, 15
s Assumptions, 16
s Workshop 1Introduction, 17
14 Introduction
VirtuuI Prototyping Process-
Youll learn to use the tools for improving your design.
Build
s Create parts
s Constrain the parts
s Define forces acting on the parts
Validate
s Import test data
s Superimpose test data on plots
Test
s Measure characteristics
s Perform simulations
s Review animations
s Review results as plots
Iterate
Refine
s Add friction
s Define flexible bodies
s Implement force functions
s Define controls
Automate
s Create custom menus
s Create custom dialog boxes
s Record and replay modeling
operations as macros
Optimize
s Perform design sensitivity
studies
s Perform design of experiments
s Perform optimization studies
Do results compare
with test data?
No
Yes
Design
problem
Cut time
and costs
Improved
product
Increase
efficiency
s Add parametrics
s Define design variables
Increase
quality
Introduction 15
How You enefit from Using Advunced ADAMS/View
QuickIy unuIyze muItipIe design vuriutions untiI you find the
optimuI design through:
s Parameterization
s Design studies, design of experiments (DOE), and optimization
Customize ADAMS/View so thut it works und Iooks the wuy you
wunt it to und mimics your design environment, You cun:
s Customize the graphical interface
s Automate your work using macros
Leurn ADAMS/View epression und commund Iunguuges
s Better understand the work of ADAMS/View
16 Introduction
Assumptions
This course assumes that you are an experienced ADAMS/View user.
Introduction 17
This workshop takes about 30 minutes to complete.
ProbIem stutement
In this workshop you will use a custom interface to solve a given problem. You need to
determine the locations of joints in a mechanism so that a disk can be dropped at a desired angle.
The customized graphical user interface (GUI) can be used several ways:
s Move joint locations
s Simulate
s Animate
s Calculate a value of interest
s Optimize
s Perform tolerance check
After using the interface provided, you will appreciate the advantages of a customized interface.
XII I
II
III
IV
V VI VII
X
XI
VIII
IX
Workshop 1-Introduction
18 Introduction
ModeI informution
This model represents a disk transfer mechanism, as shown in the figure below.
Disks are stacked in a bin and must be moved to a table. A series of links are constructed and
driven by a pulley. The joint locations for each link must be determined so that the disk is
oriented at a prescribed drop angle midway through its duty cycle. Throughout the cycle, it
should neither strike the bin nor clash with the table.
9etting sturted
To get sturted:
1 Start ADAMS/View from the mod_01_intro directory.
2 Import the command file build.cmd.
This will import the disk transfer model and the interface customizations.
3 From the View menu, select Revolve Model (custom menu button).
Familiarize yourself with the model as it revolves about the y-axis of the view window.
4 Run a 1-second/50-step simulation to see how it operates.
5 Reset the model and select a front view.
Bin
Bracket
Pulley
Table
Disk
Workshop 1-Introduction,,,
Introduction 19
Chunging the design
In this section you will see how to change key locations of your mechanism.
To chunge the modeI:
1 From the Disk Transfer menu, select Design Layout.
2 In the Design Layout dialog box, select the design point you want to modify.
Observe the current x and y coordinates in the text boxes.
3 Use the + or - button to change the point location.
Because the model is parameterized, all model dependencies update when you change these
locations.
Note: The buttons use increments of 2 mm per click.
4 Watch the model change as you press these buttons.
Note: If you move the points too far, you will encounter a hardcoded out-of-range error.
5 Reset your model to the original design by selecting Reset All.
Leave the Design Layout dialog box open and continue with the next step.
Workshop 1-Introduction,,,
20 Introduction
SimuIuting the modeI
Now youll simulate the model to see how it behaves.
To simuIute the modeI:
1 From the Disk Transfer menu, select Simulate.
2 To simulate the current design configuration, make sure that Single is selected.
3 Select Apply.
If you change the Model Display option menu from At Every Output Step to Never, the model
solves faster, but does not update on the screen.
Leave the Simulate dialog box open and continue with the next step.
Reviewing the resuIts
Now youll look at results of the simulation as an animation and a calculated value of interest.
To review resuIts:
1 From the Disk Transfer menu, select Review Results.
2 Select Animate to see the motion from your last simulation. It will also draw some
animation traces of markers at the corners of the disk.
Tip: If necessary, use the Stop button in the lower right corner of the screen to stop
an animation before it has completed.
3 Select Reset in the Review dialog box when youre done animating.
Workshop 1-Introduction,,,
Introduction 21
Determining the drop ungIe
To uutomuticuIIy find the drop ungIe:
1 Select Actual Angle in the Review dialog box to determine the drop angle of the last
simulated design.
2 What is the drop angle for the baseline design? _________________________________
3 When youre done, close the Information window.
Leave the Review dialog box open and continue with the next step.
To munuuIIy find the drop ungIe:
1 Adjust the locations of points 1, 2, and/or 4 so that the resulting drop angle is
approximately -2 degrees (relative to the table).
Note: Visually verify that the disk does not clash with the table throughout its cycle.
2 Did you succeed at finding a drop angle of -2 degrees in three tries or less?
____ Yes, my angle was ________________.
____ No, it was too difficult.
Regarding sign of drop angle relative to table, + is Clockwise, - is Counterclockwise.
Keep an eye on students that are trying too hard to manually find the drop angle. The message here is that
you cant do it very easily (using the manual method).
Workshop 1-Introduction,,,
22 Introduction
Finding the drop ungIe using optimizution-
Now, youll perform an optimization study. During the optimization, ADAMS/View
systematically varies the point locations and runs a number of simulations until the desired drop
angle is achieved.
To perform un optimizution study:
1 In the Simulate dialog box, select Optimize and enter a Desired Drop Angle of -2 degrees.
Note: We highly recommended that you use Model Display of At Simulation End to
greatly speed up the individual simulations.
As the optimization runs, you may notice that the status bar updates with the iterations and
passes used by the optimization algorithm. Please be patient, as this will take a few minutes.
A strip chart will be displayed, indicating the progress the optimizer is making by plotting
the objective versus iteration.
Once the optimization study is completed, an optimization summary will be displayed in
the Information window.
2 Which design variable coordinate had the largest percentage change from its initial
value? ________________________________
3 Which design variable coordinate had the smallest percentage change from its initial
value? ________________________________
4 What are the optimized variable values?
5 Close the Information window.
6 As a confirmation, perform a single simulation using the design configuration that the
optimizer found. Compare the desired drop angle to the actual drop angle.
7 Was the optimization study successful? _____ Yes _____ No
Remind students to reset before optimizing.
X Y
Point 1
Point 2
Point 4
Workshop 1-Introduction,,,
Introduction 23
Performing u toIerunce check
Next, you will see the effect of manufacturing tolerance on the drop angle. The optimized
configuration will be considered the nominal value.
To perform u toIerunce check:
1 In the Simulate dialog box, select Tolerance Check.
2 Using a tolerance of 1 mm, perform a tolerance check for the variables that had the
largest and smallest percent change from the optimization report (see steps 2 and 3 on
page 22).
3 Write down the value of the objective for each trial:
SpeciuI note
This workshop used the following capabilities of ADAMS/View:
s A fully parameterized model
s Design studies
s Optimization studies
s Custom menus
s Custom macros
s Custom dialog boxes
Throughout this course, these concepts and features (solutions) will be taught in detail. At the
end of this course, you will be able to do this with your own virtual prototypes.
OptionuI tusks
s Allow the disk to be dropped to the table during the simulation. Run a scripted
simulation (by selecting Scripted Controls from the ADAMS/View Simulate menu),
using .model_1.DROP_DISK_SCRIPT in the Simulation Script Name text box.
-1 mm Nominal +1 mm
DV_p4_x
DV_p2_y
Workshop 1-Introduction,,,
24 Introduction
Workshop 1-Introduction,,,
25
2
XPRSSIOMS: OVRVIW
Test your knowledge of expressions and database objects using the given
model.
Whut's in this moduIe:
s Why Use Expressions?, 26
s Expressions: Compute Values, 27
s Expressions: Parameterize, 28
s Syntax: Data Types, 30
s Syntax: Operands, 31
s Expression Builder, 35
s Syntax Pitfalls, 36
s Workshop 2Expressions: Overview, 37
x Module review, 47
26 Expressions: Overview
Why Use pressions?
Compute vuIues
Purumeterize
Expressions: Overview 27
pressions: Compute VuIues
Compute vuIues
s ADAMS performs the calculations
s Prevents errors
s Results in higher accuracy
umpIe: Shuft speed converted from rpm to rudiuns/sec
You might write the following by hand:
In ADAMS/View, you would type the following expression:
(500*2*PI/60)
Purumeterize
Here we see that an expression will be evaluated by ADAMS/View. This happens in fields that are
expecting an ADAMS/Solver function.
500
rev
min
----------


1
60
------
min
onds sec
------------------------


2
rad
rev
---------


52.359878
rad
onds sec
------------------------


=
Evaluated
28 Expressions: Overview
pressions: Purumeterize
Compute vuIues
Purumeterize u modeI
s Model characteristics can contain references to other data
s Dependencies are established
s One change propagates through the model
s Similar to defining a spreadsheet cell as a function of another cell
umpIe:
MOTION_1 references a design variable, .shaft_speed, which references another design
variable, .input_RPM.
You could also reference the design variables above in other places in the model at the same
time. When you change one, the change would be reflected in multiple places.
MOTIOM_1
FUMCTIOM
Design vuriubIe
.shaft_speed
.input_RPM
Design vuriubIe
Expressions: Overview 29
pressions: Purumeterize,,,
umpIe: Shuft speed using u design vuriubIe to store the epression-
When ADAMS/View reads an expression, it either:
s Evaluates and then stores it in the database.
s Stores the expression itself.
You can retain expressions in an ADAMS/Solver function field by using a design variable. This example
is also meant to show a chain of dependencies.
30 Expressions: Overview
Syntu: Dutu Types
Integer -
s Whole numbers
s Example: 3
ReuI
s Most numeric values
s Example: 3.14159
String
s Character strings of varying length
s Example: x
Obgect -Dutubuse obgects
s Example: .model_1.part_1.marker_2
Mutri -
s One- or two-dimensional collections of values of the same type, or one of the above
objects.
s Example: (Array of strings)
{x,y}
s Example: (Array of reals)
{[1.1, 3.4], [2.2, 4.5], [2, 3.3]}
You may want to cover the conversion functions (STOI, STOO, STOR)
Show them arrays in Function Builder Expression Language Reference.
The square brackets indicate rows in the Array example.
{
[1.1 3.4]
[2.2 4.5]
[2 3.3]
}
Expressions: Overview 31
Syntu: Operunds
Design-time functions
Dutubuse obgects und their component vuIues
Constunts
32 Expressions: Overview
Syntu: Operunds,,,
Design-time functions
s System-supplied
umpIe:-
(LOC_RELATIVE_TO({0,0,0}, .model_1.ground.marker_1))
(SIN(30d)*500)
(DB_DEFAULT(.system_defaults, MODEL))
s User-written
umpIe:
MID_PT(marker_2, marker_3)
Dutubuse obgects und their component vuIues
Constunts
The LOC_RELATIVE_TO will be covered in the next module. Consider showing DB_DEFAULT in
online docs (system supplied functions).
Expressions: Overview 33
Syntu: Operunds,,,
Design-time functions
Dutubuse obgects und their component vuIues
umpIes:-
Other usefuI operutors:-
x .name
x .parent
Constunts
Database access: Type:
.some_model.some_part.mass Real
.model_1.motion_1.comments
.model_1.circle_1.adams_id
.model_1.part_1.location
.model_1.joint_1.i
Fill in the table using Q&A with the class: real, string, integer, real array, object
Other useful operators:
.name -- returns the short name of the object
.parent -- returns the parent of the object
34 Expressions: Overview
Syntu: Operunds,,,
Design-time functions
Dutubuse obgects und their component vuIues
Constunts
umpIes:
RTOD 180
o
/ (Radians TO Degrees)
PI 3.14159
TRUE 1
NONE Used to erase values in the database.
For more information on constants, refer to the section, Symbolic Constants, in the guide,
Using the ADAMS/View Function Builder.
Expressions: Overview 35
pression uiIder
To test or prototype your expressions, you can access the Function Builder in expression-
building mode (Expression Builder) by selecting it from the ADAMS/View Tools menu, or
from the Design Variable dialog box.
Demo the expression builder.
Expression categories
Getting object data
(Data dictionary)
Expression work area
Example
OR
36 Expressions: Overview
Syntu PitfuIIs
Forgetting purentheses
s An expression must be wrapped in parentheses to be recognized.
s (()
Forming urruys incorrectIy
s Defining a 3 x 1 array when a 1 x 3 array is expected, or the reverse.
s Indexing incorrectly. See the guide, Using the ADAMS/View Function Builder, for
syntax examples.
Need another closing parenthesis
Expressions: Overview 37
This workshop takes about 30 minutes to complete.
ProbIem stutement
Test your knowledge of expressions and database objects using the given model.
ModeI description
s The model is made up of linkages that move based on various joints, motions, and
springs.
XII I
II
III
IV
V VI VII
X
XI
VIII
IX
Workshop Z-pressions: Overview
38 Expressions: Overview
9etting to know epressions
Before you import the model, take a quiz on the different data types that youll investigate in
this model. It is okay if youre unsure, just guess. By the end of this workshop, youll have a
better understanding of the data types.
Quiz:
Match the items in the left column with the choices in right column. Weve done one for you.
ADAMS modeI churucteristics:
1 An entitys ID
2 Material type for a part
3 Comments for a design variable
4 Name of I marker for a joint
5 Stiffness coefficient for a spring
6 The joint that is used by a motion
7 Diagonal for a box
Dutu types:
String
Integer
Object
Real
String
Matrix (Array of reals)
Object
Workshop Z-pressions: Overview,,,
Expressions: Overview 39
9etting sturted
To set up the modeI:
1 Start ADAMS/View from the directory exercise_dir/mod_02_expressions.
Throughout the rest of the course we will not refer to exercise_dir. All workshops can be
found in the same path.
2 From this directory, import the model command file express_test.cmd.
3 To get familiar with the model, simulate it:
s End time: 1.25
s Steps: 50
4 Shade the model by selecting Render from the Main Toolbox.
5 Perform a looped animation:
s From the Main toolbox, select the Animation tool .
s At the bottom of the container, select Loop, and then select the Play tool .
6 Stop the animation using the Stop tool .
Using fuII numes
In version 11.0 of ADAMS/View, the default name setting is to display short names. This means
that the full name will not be shown in the various fields and functions. Instead, the shortest
unique name will be shown whenever possible. Since youre here to learn about the details of
expressions, you need to reset the default to full names. You may want to do this later in the
course as well.
To use fuII numes:
1 From the Settings menu, select Names.
2 In the Default Names dialog box, select Full Names.
3 Select OK.
Workshop Z-pressions: Overview,,,
40 Expressions: Overview
Accessing the pression uiIder
To uccess the pression uiIder:
1 From the Build menu, point to Design Variables, and then select New.
2 Right-click the Standard Value text box, point to Parameterize, and then select Expression
Builder.
The Expression Builder appears.
3 Clear the 0 from the Expression work area.
Expression work area
Workshop Z-pressions: Overview,,,
Expressions: Overview 41
Find the muteriuI of purt: rt_buse
You will now use the Expression Builder to find various object data. There are three major steps
to finding object data in the Expression Builder, as shown in the following figure:
1 Find the object
2 Get the data owned by the object
3 Evaluate the data
Step 3 - Evaluate
Step 2 - Get Data
Step 1 - Find Object
Workshop Z-pressions: Overview,,,
42 Expressions: Overview
Step 1 - To find the purt:
1 In the Getting Object Data section, change the menu that has Markers currently selected to
Parts.
2 Right-click the text box to the right of that menu, point to Part, and then select Browse.
The Database Navigator appears.
3 Under the model name, express_test, select rt_base.
4 Select OK.
The text box now has .express_test.rt_base in it.
Step Z - To get dutu owned by the purt in this cuse muteriuI:
1 Select Get Data Owned By Object.
A Selection menu appears. It is often referred to as the database dictionary.
2 From that menu, select material.
3 Click OK.
Notice that the work area section of the Expression Builder now has
.express_test.rt_base.material in it.
Step 3 - To evuIuute the epression:
1 Select Evaluate.
2 Use the value that is in the Function Value: section, below the work area, to answer the
first part of Question 1 in the Module review on page 47.
Workshop Z-pressions: Overview,,,
Expressions: Overview 43
Checking the dutu type
Before you can use the object data, often you may need to understand its data type. In this
section, youll check the data type of the object you found.
To check the dutu type:
1 Select OK in the Expression Builder to close it.
2 Notice the following in the Create Design Variable dialog box:
x The material is now in the Standard Value text box as:
(.express_test.rt_base.material)
x The Type menu is set to Real.
Now well use warning messages as an indirect way of learning an objects type.
3 Right-click the Standard Value text box, point to Field Info, and then select Validate.
A Warning window appears with the message:
Invalid conversion from database object to real number
The message indicates that the text box expects a real number, but you entered a database
object, and that it is trying but unable to convert it. This exercise just shows you how to tell
which data type it is: database object.
4 Return to Question 1 in the Module review on page 47 to answer the last part of the
question.
Workshop Z-pressions: Overview,,,
44 Expressions: Overview
9etting more component vuIues of dutubuse obgects
Now youll practice finding component values of database objects, including design variables,
diagonals of geometry, and more.
To find the comments thut ure purt of design vuriubIe ,wing_Iength:
1 Open the Expression Builder again.
2 Clear the information in the work area.
3 In the Getting Object Data section, change the menu to Design Variables.
4 Right-click in the text box to the right of that menu, point to Variable, and then select
Browse.
The Database Navigator appears.
5 Under the model name, express_test, select wing_length.
6 Select OK.
The text box now has .express_test.wing_length in it.
To get the dutu owned by the obgect in this cuse comments:
1 Select Get Data Owned By Object.
2 From the Selection menu, select comments.
3 Select OK.
Notice that the work area section of the Expression Builder now has
.express_test.wing_length.comments in it.
To evuIuute thut epression:
s Select Evaluate.
Workshop Z-pressions: Overview,,,
Expressions: Overview 45
To check the dutu type:
1 Select OK in the Expression Builder to close it.
2 Notice the following in the Create Design Variable dialog box:
x The comments are now in the Standard Value text box as:
(.express_test.wing_length.comments)
x The Type menu is set to Real.
3 Right-click the Standard Value text box, point to Field Info, and then select Validate.
A Warning window appears with the message:
Invalid conversion from character string to real number
The message indicates that the text box expects a real number, but you entered a character
string, and it is trying but unable to convert it. This exercise just shows you how to tell
which data type it is: character string.
4 Answer Question 2 in the Module review on page 47 using the information you found.
Workshop Z-pressions: Overview,,,
46 Expressions: Overview
5 Now repeat these steps to find the following database objects and answer the associated
question in Module review on page 47.
Hint: You can also access the Function Builder directly by selecting Function Builder from
the Tools menu. It is a quick way to test out function syntax when writing macros.
Find the database object: Tips:
Use the value
to answer:
I marker for the joint: jt_rt_pillar Use the i choice. Question 3
Diagonals for the box geometry:
.rt_base. BOX_2
Use the diag choice in the
data dictionary.
Question 4
Stiffness coefficient for the spring:
spring_piston_cylind
Because the spring owns
this component value
directly, you must browse
one level deeper in the
Database Navigator to find
stiffness_coefficient and
then get the data owned by
the element.
Question 5
Name of the joint that is used by
motion: mot_rt_pillar
Use the .name operator. Question 6
ADAMS ID for the part: .lt_wing Question 7
Workshop Z-pressions: Overview,,,
Expressions: Overview 47
ModuIe review
1 What is the material for the part: .rt_base? What is its data type?
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
2 What is the comment that is part of the design variable: .wing_length? What is its data
type?
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
3 What is the I marker for the joint: jt_rt_pillar? What is its data type?
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
4 What are the diagonals for the box geometry: .rt_base. BOX_2? What is their data type?
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
5 What is the stiffness coefficient for the spring: spring_piston_cylind? What is its data
type?
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
6 What is the name of the joint that is used by motion: .mot_rt_pillar? What is its data type?
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
7 What is the ADAMS ID for the part: .lt_wing? What is its data type?
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
Remind them that using .name will return a string. Its the non-fully specified name.
Workshop Z-pressions: Overview,,,
48 Expressions: Overview
Workshop Z-pressions: Overview,,,
49
3
XPRSSIOMS: FUMCTIOMS
Fully parameterize the given cylinder, such that its location, orientation, and
shape are tied to a pair of markers.
Whut's in this moduIe:
s Functions Overview, 50
s Functions: Location, 51
s Functions: Orientation, 52
s Functions: Modeling, 53
s Functions: User-Written, 54
s Expressions: Saving Your Work, 55
s Workshop 3Expressions: Functions, 56
x Module review, 67
Not a very exciting model, but it drives home some key concepts.
50 Expressions: Functions
Functions Overview
ight Cutegories of Functions:
Math
x Apply to scalar numbers or matrixes.
Location/Orientation
x Compute one or more locations or orientations from a variety of input
parameters
Modeling
x Return a requested displacement measurement between markers or parts
Matrix/Array
x Allow you to easily perform common matrix operations
String
x Allow you to manipulate character strings
Database
x Facilitate your access to the database
File
x Allow you to read information from and write information to files
Miscellaneous
x Database functions
x Interface (GUI) functions
x String functions
x System functions
Note: There are several functions of each type. In this section, well cover some of the
common types.
Cover online help, if you havent done so already.
Expressions: Functions
51
Functions: Locution
LOC_RLATIV_TO-
Definition
Returns an array of three numbers, representing a location, by transforming a specified
location that is relative to a coordinate system object.
Formut
LOC_RELATIVE_TO (Location, Frame Object)
umpIe
LOC_RELATIVE_TO({16,8,0}, marker_2)
Note: The Location is an array. In Workshop 6Performing a Design Study on page 121,
you will use another function to return an array. Using this method, you can nest
functions.
Demo the use of LOC_RELATIVE_TO so they understand global and local frames.
(16,8,0)
marker_2
(4,6,0)
(-4,22,0)
(0,0,0)
y
G
x
G
z
G
y
x
z
52 Expressions: Functions
Functions: Orientution
ORI_ALOM9_AXIS-
Definition
Returns the alignment of a specified axis from one coordinate system object to another.
ORI_ALONG_AXIS has an underlying parameter that allows it to express the resulting
orientation in the correct coordinate system object.
Formut
ORI_ALONG_AXIS (From Frame, To Frame, Axis Name)
umpIe
ORI_ALONG_AXIS(marker_1, marker_2, y)
Note: From Frame and To Frame must be objects. They cannot be arrays.
Demo it with some markers.
Students may wonder what happens to the other axes if you only specify Y. Explain that they are de-
faulted, and if they want to control them, they should use ORI_IN_PLANE.
marker_1
marker_2
(0,0,0)
x
G
y
G
z
G
(250,150,0)
(400,300,0)
x
z
y
x
z
y
y
Expressions: Functions
53
Functions: ModeIing
DM-
Definition
Returns the magnitude of the translational displacement from one coordinate system
object to another.
Formut
DM (Object 1, Object 2)
umpIe
DM (marker_O1, marker_O2)
In this example, DM=13.
Its use is significantly different from the run-time DM function.
marker_O2
marker_O1
R
T
R
F
global
-5
12
13
origin
54 Expressions: Functions
Functions: User-Written
Two types of user-written functions-
Interpreted Functions
s Interpreted functions consist of text inserted into an expression when ADAMS
evaluates the expression.
s You can create these functions in the Command Window, using the FUNCTION
command.
s When you create them, you must specify the text of the function and the parameter
names.
s Example:
x MIDPT (marker_2, marker_3)
CompiIed Functions
s These functions are written in C or FORTRAN and linked into ADAMS/View.
s You can use these functions in the same way you would use the built-in functions.
KB 7219 contains an example of the MID_PT function. You may want to consider demonstrating it.
Mention that MID_PT is an example in the guide, Using the ADAMS/View Function Builder.
Expressions: Functions
55
pressions: Suving Your Work
ADAMS/View commund fiIe {,cmd}
s Command file format is the best way to archive and store models. It can be slower,
but its not prone to corruption.
s Expressions are at the bottom of the command file.
ADAMS/View dutubuse fiIe {,bin}
s Parameterized model resides in the ADAMS/View database.
s Opens quickly.
ADAMS/SoIver dutuset fiIe {,udm}
s Parametric expressions are not stored in an ADAMS/Solver dataset.
s Small size.
Note: For additional information on the advantages and disadvantages of the various file
types, refer to the Knowledge Base Article 7248 available at:
http://support.adams.com/kb/faq.asp?ID=7248.
56 Expressions: Functions
This workshop takes about 30 minutes to complete.
ProbIem stutement
Fully parameterize the given cylinder, such that its location, orientation, and shape are tied to a
pair of markers.
ModeI description
s The given model is a cylinder that currently has no parameterization.
s Its length is 800 mm and its radius is 100 mm.
s The cylinder has two markers, one of which (MARKER_1) is the center marker for the
cylinder geometry.
s You will create markers to serve as the guides for the cylinders location, orientation,
and length.
XII I
II
III
IV
V VI VII
X
XI
VIII
IX
Workshop 3-pressions: Functions
Expressions: Functions 57
9etting sturted
To set up the modeI:
1 Start ADAMS/View from the mod_03_functions directory.
2 Import the file cyl_mod_start.cmd.
3 From the Settings menu, select Names.
4 In the Default Names dialog box, select Full Names.
5 Select OK.
To turn on the visibiIity of icon numes for murkers:
1 From the Settings menu, select Icons.
2 In the middle of the dialog box, select Markers, and then set Name Visibility to On.
3 Select OK.
To become fumiIiur with the modeI:
s Notice that it has:
x One part
x One cylinder geometry
x Two markers
(center marker for cylinder)
cm
(center of mass marker for part)
MARKER_1
Workshop 3-pressions: Functions,,,
58 Expressions: Functions
Creuting murkers
First youll create two markers to be used for parameterization. Refer to the figure below for
location information.
To creute guide murkers:
1 Create a marker named guide_1:
s Attached to ground
s With global orientation
s Located on the left end of the cylinder (0,0,0)
It will snap to PART.MARKER_1.
2 Create another marker named guide_2:
s Attached to ground
s With global orientation
s Located on the right end of the cylinder (800,0,0).
It will snap to PART.CYLINDER_1.E1 (center).
3 Get info on the markers if you want to verify that they are located correctly.
guide_2 guide_1
(0,0,0)
(800,0,0)
Workshop 3-pressions: Functions,,,
Expressions: Functions 59
Purumeterizing the Iocution of the cyIinder
To parameterize the location of the cylinder, you actually parameterize the location of the center
marker for the cylinder geometry (not the center of mass marker for the part).
To obtuin informution ubout the cyIinder:
1 Right-click the cylinder, point to Cylinder: CYLINDER_1, and then select Info.
2 What is the center marker for the cylinder? ___________________________________
Because that marker controls the location of the cylinder, you want to parameterize its
location to guide_1 using a location function.
3 Select Close to close the Information window.
To purumeterize the Iocution of the murker:
1 Right-click the center marker, point to its name, and then select Modify.
2 Right-click the Location text box, point to Parameterize, and then select Expression Builder.
3 Clear the 0.0, 0.0, 0.0 entry from the work area.
4 Change the function category from Math Functions to Location/Orientation.
5 From the Selection menu, highlight LOC_RELATIVE_TO.
6 Select Assist.
7 Because you want the center marker to remain coincident with the marker guide_1, in the
Location text box, enter 0,0,0.
8 Right-click the Frame Object text box, point to Position, and then select Browse.
The Database Navigator appears.
9 Select the marker .ground.guide_1, and then select OK.
Workshop 3-pressions: Functions,,,
60 Expressions: Functions
10 From the assist dialog box, select OK.
The following function appears in the work area of the Expression Builder:
11 In the Expression Builder, select Evaluate to verify that the expression does not contain
errors.
12 Select OK.
13 In the Marker Modify dialog box, select OK.
To test the purumeterizution
To test the parameterization, youll modify the location of the guide markers using the Table
Editor and see if the location of the cylinder follows.
1 Select the ADAMS/View background to clear the selection of any objects.
2 From the Tools menu, select Table Editor.
3 Position the Table Editor so you can see the cylinder while you enter values in the Table
Editor.
4 Along the bottom left of the Table Editor, select Markers.
Notice that markers are now listed in the Table Editor, instead of parts.
5 In the lower right corner, select Filters.
LOC_RELATIVE_TO( {0,0,0} , .cyl_mod.ground.guide_1 )
An array
Workshop 3-pressions: Functions,,,
Expressions: Functions 61
6 In the dialog box, do the following:
s Ensure that the top text box, Scope, contains .cyl_mod so all markers in the model
appear.
s Clear the selection of (that is, uncheck):
x Adams ID
x Loc. and Ori. Components in Individual Columns
s Select Orientation.
s Ensure that Location is selected (Only Location and Orientation need to be selected).
s Select OK.
7 In the Location cell for ground.guide_1, change the coordinates from 0,0,0 to 150,200,0.
8 Select Apply.
s Watch the cylinder change based on the location of guide_1.
s Notice that the marker guide_2 stays in the same location.
Be sure to include the . (dot)
guide_2
guide_1
Workshop 3-pressions: Functions,,,
62 Expressions: Functions
Purumeterizing the orientution of the cyIinder
The z-axis of the center marker of the cylinder defines the direction of the cylinder. You are now
going to parameterize that marker so that its z-axis always points from guide_1 to guide_2.
To purumeterize the orientution of the cyIinder:
1 Go back into the Table Editor and, if necessary, display markers again.
2 Select the Orientation cell for PART.MARKER_1.
3 Right-click the Input box at the top of the Table Editor, point to Parameterize, and then
select Expression Builder.
4 Clear the 90, 90, 0 entry in the work area of the Expression Builder.
5 Change the function category from Math Functions to Location/Orientation.
6 From the Selection menu, select ORI_ALONG_AXIS.
7 Select the Assist button.
Workshop 3-pressions: Functions,,,
Expressions: Functions 63
8 In the assist dialog box:
s Right-click the From Frame text box, point to Position, and then select Browse. From the
Database Navigator, select the marker guide_1.
s Right-click the To Frame text box, point to Position, and then select Browse. From the
Database Navigator, select the marker guide_2 marker.
s Set Axis Name to Z.
s Select OK.
The following expression now appears in the work area:
ORI_ALONG_AXIS( .cyl_mod.ground.guide_1 , .cyl_mod.ground.guide_2 , "Z" )
9 Select Evaluate to preview the orientation angles.
The orientation angles should be roughly 72.897, 90, 270.
10 In the Expression Builder, select OK.
11 In the Table Editor, select OK.
Notice that the cylinder now points from guide_1 to guide_2, but the length of the cylinder
does not change depending on distance between the two markers.
guide_1
guide_2
Workshop 3-pressions: Functions,,,
64 Expressions: Functions
Purumeterizing the Iength of the cyIinder
Now youll parameterize the length of the cylinder so that it depends on the distance between
markers guide_1 and guide_2.
To purumeterize the Iength of the cyIinder:
1 Right-click the cylinder, point to Cylinder:CYLINDER_1, and then select Modify.
2 Right-click the Length text box, point to Parameterize, and then select Expression Builder.
3 Clear the (800 mm) that appears in the work area of the Expression Builder.
4 Set the Function category to Modeling Functions.
5 From the Selection menu, highlight DM.
6 Select the Assist button.
7 In the assist box:
s Right-click the Object 1 text box, point to All, and then select Browse. In the Database
Navigator, select the marker guide_1.
s Right-click the Object 2 text box, point to All, and then select Browse. In the Database
Navigator, select the marker guide_2.
The following expression now appears in the work area:
DM( .cyl_mod.ground.guide_1 , .cyl_mod.ground.guide_2 )
8 In the Expression Builder, select OK.
9 In the Geometry Modify Shape Cylinder dialog box, select OK.
10 Move the two guide markers around and notice how the cylinder keeps its ends on top of
the two markers.
Workshop 3-pressions: Functions,,,
Expressions: Functions 65
Purumeterizing the rudius of the cyIinder
You now parameterize the radius so that it is always 1/8th of the cylinder length.
To purumeterize the rudius of the cyIinder:
1 Open the Geometry Modify Shape Cylinder dialog box for the cylinder again.
2 Right-click the Radius text box, point to Parameterize, and then select Expression Builder.
3 Clear the (100 mm) that appears in the work area.
4 Enter (1.0/8)* in the work area.
5 In the Getting Object Data section, set the menu to All Objects.
6 Right-click the text box to the right of the menu, point to All, and then select Browse. In
the Database Navigator, browse for and select the cylinder geometry (Cylinder_1).
7 Select Get Data Owned by Object.
8 From the Selection menu, select length.
9 Select OK.
The following expression now appears in the work area:
(1.0/8)*.cyl_mod.PART.CYLINDER_1.length
10 In the Expression Builder, select OK.
Notice how it was automatically wrapped in parentheses for you.
11 In the Geometry Modify Shape Cylinder dialog box, select OK.
Workshop 3-pressions: Functions,,,
66 Expressions: Functions
Testing the purumeterizution
s Move the guide markers around and notice that the location, orientation, length, and
radius change accordingly, as shown in the next figures.
Workshop 3-pressions: Functions,,,
Expressions: Functions 67
ModuIe review
1 Consider the ramifications of parameterizing both the center-of-mass location and the
length. Is there a conflict?
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
2 You have parameterized the cylinder length using the DM design-time function. Can the
cylinder length be dependent on a run-time variable?
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
3 Could the cylinder length be dependent on a STEP function? Why might you want to do
that?
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
Note: For more information on this topic, refer to the Knowledge Base Article 8464
available at: http://support.adams.com/kb/faq.asp?ID=8464.
Workshop 3-pressions: Functions,,,
68 Expressions: Functions
Workshop 3-pressions: Functions,,,
69
4
PARAMTRICS: OVRVIW
Parameterize the locations of points in the model, and then plot toe angle for
different configurations of the given suspension model.
Whut's in this moduIe:
s Tools for Parametrics, 70
s Workshop 4Parameterizing an Existing
Model, 76
70 Parametrics: Overview
F{} on Muin TooIbo
F{} on Muin TooIbo
Use of construction point
Purumetrics in verticuI uppIicutions
TooIs for Purumetrics
Parametrics: Overview 71
F{} on Muin TooIbo
Ties the location of one object to another.
Options:
s Collapse - Maintains no offset
LOC_RELATIVE_TO({0,0,0}, Frame Object)
s Maintain - Maintains existing offset
LOC_RELATIVE_TO({<existing offset>}, Frame Object)
F{} on Muin TooIbo
Use of construction points
Purumetrics in verticuI uppIicutions
TooIs for Purumetrics,,,
72 Parametrics: Overview
F{} on Muin TooIbo
F{} on Muin TooIbo
Option 1:
ORI_RELATIVE_TO
s Collapse - Maintains no offset
s Maintain - Maintains existing angular offset
Option Z {most common}:
ORI_ALONG_AXIS
s Step 1 - Pick object
s Step 2 - Choose object and axis simultaneously
s Step 3 - Pick last object
Option 3:
ORI_IN_PLANE
Use of construction points
Purumetrics in verticuI uppIicutions
TooIs for Purumetrics,,,
Parametrics: Overview 73
F{} on Muin TooIbo
F{} on Muin TooIbo
Use of construction points
s The difference between a marker and a point is that you can define location and
orientation on a marker, but can only define location on a point.
s Can belong to any part, but the grounded part is typically chosen.
s Typically used to tie mechanism information (geometry, joints, forces, and so on) to
that key location of interest.
Options:
s Dont Attach: Parametric relationships not formed at the location.
s Attach Near: Applies the LOC_RELATIVE_TO expression to locations of all visible
objects close to the point being created. The algorithm used to define close is a
function of screen coordinates, not mechanism length units. When you right-click on
an object, the Select dialog box opens, displaying the objects that are considered
close to that object. Notice in the example shown on the next page, that as you
zoom out, the number of close objects increases.
TooIs for Purumetrics,,,
74 Parametrics: Overview

Tell the students that they can change the pick tolerance (currently 0.015) by using the instructions in
mod_04_sla/misc/readme.txt. Also, the example shown above can be found in mod_04_sla/
misc/test_pick_tol.cmd.
Zoomed in
Zoomed out
More
objects
attached
TooIs for Purumetrics,,,
Parametrics: Overview 75
F{} on Muin TooIbo
F{} on Muin TooIbo
Use of construction points
Purumetrics in verticuI uppIicutions
Parametrics in the ADAMS vertical products are based on a slightly different paradigm. They
use hardpoints and construction frames. For more information, refer to the tutorials in the
guides, Getting Started Using ADAMS/Car and Getting Started Using ADAMS/Engine.
TooIs for Purumetrics,,,
76 Parametrics: Overview
This workshop takes about one hour to complete.
ProbIem stutement
Parameterize the locations of points in the model, and then plot toe angle for different
configurations of the given suspension model.
ModeI description
s The model has five parts (not including ground).
s All appropriate constraints are in the model.
s There are markers attached to ground at each key location (see the figure on the next
page).
s There is a point motion driving the spindle up and down 100 mm.
s There is one function measure that calculates toe angle, and one that calculates wheel
height.
Be sure to explain that ADAMS/View isnt meant for suspension analysis, the vertical applications,
ADAMS/Car and ADAMS/Pre, are. The context here is to understand parametrics. Understanding para-
metrics will help you create better ADAMS/Car templates.
XII I
II
III
IV
V VI VII
X
XI
VIII
IX
Workshop 4-Purumeterizing un isting ModeI
Parametrics: Overview 77
9etting sturted
To import the modeI:
1 Start ADAMS/View from the mod_04_sla directory.
2 Import the sla_start.cmd file.
9etting fumiIiur with points
To identify the purts:
1 Simulate the model to observe its behavior:
s End Time: 1
s Steps: 50
2 Get to know the part names and the locations of the reference markers in the suspension.
Label the parts in the figure below. UCA has been done for you.
Tip: Use the Database Navigator in Browse and Highlight modes.
pnt5_ref
pnt7_ref
pnt2_ref
pnt1_ref
pnt4_ref
pnt3_ref
pnt11_ref
pnt10_ref
pnt6_ref
pnt9_ref
pnt8_ref
UCA
Workshop 4-Purumeterizing un isting ModeI,,,
78 Parametrics: Overview
Purumeterizing the tierod
In this section, you parameterize the tierod objects (geometry and joints) to markers pnt7_ref and
pnt8_ref.
To purumeterize the Iocution of the tierod geometry:
1 Find out the name of the marker that is the center marker for the cylinder geometry that
makes up the tierod. It is ______________________________________________.
2 Turn on the appearance of that marker:
s Select the marker by adding it to the select list.
s From the Edit menu, select Appearance.
s Set Visibility to On.
3 Parameterize the location of that center marker to pnt7_ref using the location
parameterization tool, f(x).
s From the Main toolbox, in the Move toolstack, select the f(x) tool.
s Set the menu to Collapse (distance).
s Follow the prompts that appear in the status bar:
x Select the marker you want to parameterize (tierod_geo_base).
x Select the marker to which you want to parameterize (pnt7_ref).
4 Display the modify dialog box for the marker tierod_geo_base.
pnt7_ref pnt8_ref
Workshop 4-Purumeterizing un isting ModeI,,,
Parametrics: Overview 79
5 What is in the Location text box? ________________________________________
You should see a parametric expression that ADAMS/View just wrote for you.
To purumeterize the orientution of the tierod geometry:
1 Parameterize the z-axis of the center marker so it points from pnt7_ref to pnt8_ref using the
orientation parameterization tool, f().
s From the Main toolbox, in the Move toolstack, select on the f() tool.
s Set the first menu to Along Axis.
s Set the second menu to Z.
s Following the prompts:
x Select the object whose orientation you want to parameterize (tierod_geo_base).
x Define the axis start location (pnt7_ref).
x Define the axis end location (pnt8_ref).
2 Display the modify dialog box for the marker tierod_geo_base.
3 What is in the Orientation text box? ___________________________
You should see a parametric expression that ADAMS/View just wrote for you.
4 Move pnt7_ref upwards (as shown in the figure below), and make sure the cylinders
location and orientation are changing accordingly.
5 Does the length of the cylinder adjust parametrically? ______Yes ______ No
Workshop 4-Purumeterizing un isting ModeI,,,
80 Parametrics: Overview
To purumeterize the Iength of the tierod geometry:
s Parameterize the cylinders length to change based on the locations of pnt7_ref and
pnt8_ref.
Tip: Use the DM function just as you did in Workshop 3Expressions: Functions
on page 56.
To purumeterize the universuI goint:
1 Use the f(x) tool to parameterize the universal joint to pnt7_ref.
2 Obtain information about the I and J markers associated with that joint.
Hint: Select Verbose in the Information window.
3 Do you see a parametric expression written for the location of each marker?
_____Yes _____ No
The f() tool is not as useful for the orientation of the universal joint because of the
complexity of the I and J marker orientations. Therefore, we will leave this joint alone for
now.
Workshop 4-Purumeterizing un isting ModeI,,,
Parametrics: Overview 81
Purumeterizing the upper controI urm {ucu}
You will now parameterize the cylindrical geometry of the UCA part. This time you will use
design points as well as parametric expressions. The long and short cylinders will be treated
differently in the ways they are parameterized.
A markers icon must be visible on the screen if you want to parameterize using graphical
methods. Therefore, you need to turn on some marker icons.
To dispIuy murker icons:
s Display the icons for the center_marker of each cylinder belonging to the UCA part.
Tip: Turn the visibility of the center_marker on and off by using the command files
cntr_mar_on.cmd and cntr_mar_off.cmd in the subdirectory utils (use the F2 shortcut
key). This is a utility weve custom written for this workshop, and you can
customize it for other models.
To purumeterize the Iocution of the Iong cyIinders:
1 Create a design point:
s Set its characteristics to:
x Add to Ground
x Attach Near
s Select ground.pnt3_ref as the point location.
Right-click here
at pnt3_ref
Workshop 4-Purumeterizing un isting ModeI,,,
82 Parametrics: Overview
2 Use the Command Window (F3 shortcut key) to review the commands issued during the
point creation.
3 How many markers were automatically parameterized?
Circle the best answer: 1 2 3
4 Create another design point, this time selecting ground.pnt4_ref as the point location.
To purumeterize the orientution of the Iong cyIinders:
1 From the Main Toolbox, select the F() tool.
2 Set the characteristic to Along Axis and the Axis to Z.
3 Right-click the location shown in the figure on page 81.
4 Select the object whose orientation you want to parameterize (uca.uca_geo1_base).
5 Define the axis start location (pnt3_ref).
6 Define the axis end location (ground.pnt6_ref).
7 Use the Command Window to review what commands were issued during the F()
parameterization.
8 Select F() again.
9 Set the characteristic to Along Axis and the Axis to Z.
10 Select the object whose orientation you want to parameterize (uca_geo3_base).
11 Define the axis start location (pnt4_ref).
12 Define the axis end location (pnt6_ref).
To purumeterize the Iength of the Iong cyIinders:
s Use an expression to define the cylinder length so that it updates parametrically as the
endpoints change.
Tip: Use the DM function (again).
Workshop 4-Purumeterizing un isting ModeI,,,
Parametrics: Overview 83
To purumeterize the orientution of the short cyIinders:
1 From the Main Toolbox, select the F() tool
2 Set the characteristic to Along Axis and the Axis to Z.
3 Right-click the location shown next:
4 Select uca_geo2_base.
5 Select pnt3_ref.
6 Select pnt4_ref.
7 Choose F() again.
8 Set the characteristic to Along Axis and the Axis to Z.
9 Right-click the other short cylinders end.
10 Select uca_geo4_base.
11 Select pnt4_ref.
12 Select pnt3_ref.
Right-click
here
Workshop 4-Purumeterizing un isting ModeI,,,
84 Parametrics: Overview
To inspect the behuvior of short cyIinder purumetrics:
Its a good idea to test the parametrics as you build them. This follows the crawl-walk-run
process that we teach. You will move one of the design points and see what happens.
1 Select the design point at pnt3_ref (POINT_32).
2 Set the view to the right.
3 Using the Move tool, translate (10 cm) upward in the global z direction.
4 Inspect the model from different viewpoints.
5 Do the centerlines of the short cylinders pass through pnt3_ref and pnt4_ref?
____ Yes ____ No
6 What do you think went wrong? __________________________________________
_________________________________________________________________
To purumeterize the Iocutions of the short cyIinders:
1 Display the modify dialog box for marker uca.uca_geo2_base.
2 Clear the Location text box.
Tip: To quickly clear a text box, left-click the start of the text box, and then press Ctrl-k.
3 In the Location text box, point to Parameterize, and then select Expression Builder.
4 In the Expression Builder, set the function category to Location/Orientation.
5 From the Selection menu, highlight LOC_ALONG_LINE, and then select Assist.
Before moving POINT_32 After moving POINT_32 up 10 cm
Workshop 4-Purumeterizing un isting ModeI,,,
Parametrics: Overview 85
6 In the assist dialog box, set the options to:
s Object for Start Point: pnt3_ref
s Object for Point on Line: pnt4_ref
s Distance: -0.5
7 Select OK.
The expression is now in the work area.
You want to change the distance from -0.5 to be half of the cylinder's length so youll
multiply the -0.5 by the cylinder length.
8 Place your cursor after the -0.5, type the multiplier operator, for example, type asterisk, *.
9 Use the Getting Object Data section to obtain the length of the cylinder uca_geo2.
When you are done, your expression should look like:
LOC_ALONG_LINE( pnt3_ref , pnt4_ref , -0.5*uca_geo2.length )
10 Select Evaluate to verify syntax and see the location array values.
11 In the Expression Builder, select OK.
Notice that the expression is sent to the Marker Modify dialog box, and in the process, the
Expression Builder automatically wrapped the expression in the required parentheses.
12 In the Marker Modify dialog box, select Apply.
The short cylinder adjusts its location.
13 Place your cursor at the start of the Location text box. Press Shift-End to select all of the
text. Then, right-click in the Location text box, and select Copy to save the expression,
which you will paste later.
14 In the Name text box, browse for uca_geo4_base.
15 Clear the entry in the Location text box.
16 Paste the text you saved in Step 13.
17 Hand-edit the expression to be as follows:
(LOC_ALONG_LINE(pnt4_ref, pnt3_ref, -0.5 * uca_geo4.length))
18 In the Marker Modify dialog box, select Apply.
Workshop 4-Purumeterizing un isting ModeI,,,
86 Parametrics: Overview
The short cylinder adjusts its location.
19 Using the Table Editor, move POINT_32 back to its original position (384.0, 1330.0, 710.348).
Purumeterizing construints connected to UCA
To dispIuy goint murker icons:
Again you will need the marker icons to use the parameterization tools. Therefore, you need to
turn on some joint marker icons.
s Display the marker icons for all the joints connected to the UCA part.
Tip: Turn joint marker visibility on and off by using jnt_mar_on.cmd and
jnt_mar_toggle.cmd in the subdirectory utils (use the F2 shortcut key). This is another
utility weve custom written, and you can customize it for use on other models. The
I and J markers for the joints are displayed, colored maize and blue, respectively.
To purumeterize the Iocution of the UCA-spindIe sphericuI goint:
1 Create a design point:
s Set its characteristics to:
x Add to Ground
x Attach Near
s Select ground.pnt6_ref as the point location.
Workshop 4-Purumeterizing un isting ModeI,,,
Parametrics: Overview 87
2 Use the Command Window (F3 shortcut key) to review what commands were issued
during the point creation.
3 Were the joint markers parameterized to pnt6_ref or to the design point?
______________________________
4 If you dragged pnt6_ref to a new location would the spherical joint move as well?
____ Yes _____ No
5 What do you think would happen?___________________________________________
______________________________________________________________________
To purumeterize the Iocution of UCA_ground_rev revoIute goint:
1 Parameterize the location of the revolute joint's J marker uca.uca_ground_rev2 so it lies
halfway between the ground markers, pnt3_ref and pnt4_ref.
Tip: Use the LOC_ALONG_LINE() function and + 0.5*DM().
2 Use the f(x) tool to collapse the location of I marker, ground.uca_ground_rev1, onto the
J marker, uca.uca_ground_rev2.
Earlier in this workshop, you parameterized the tierod universal joint using the f(x) tool. That
simultaneously parameterized the underlying I and J markers of the joint using a
LOC_RELATIVE_TO function. In the next section, you need to use the LOC_ALONG_LINE
function so you parameterize the joint markers one at a time.
Mention that the completed .sla model is a command file written by hand. They might want to review it
as an intro to what command language looks like. Command language will be covered in Workshop 9
Understanding the Command Language on page 174.
Parameterize this
joint (UCA_ground_rev)
Workshop 4-Purumeterizing un isting ModeI,,,
88 Parametrics: Overview
Purumeterizing the orientution of UCA_ground_rev revoIute goint
In this section, you want the joint markers to be oriented such that the z-axis points from pnt3_ref
to pnt4_ref and the x-axis lies in the plane of the three points: pnt3_ref, pnt4_ref, and pnt6_ref.
To purumeterize the orientution of the J murker:
s Write an function expression for the orientation of uca.uca_ground_rev2 as follows:
(ORI_IN_PLANE( pnt3_ref , pnt4_ref , pnt6_ref , "Z_ZX" ))
To purumeterize the orientution of the I murker:
1 Use the F() tool to collapse the orientation of I marker, ground.uca_ground_rev1, onto the
J marker, uca.uca_ground_rev2.
2 Inspect the commands issued to the Command Window.
3 Which of the following functions was used? Circle the best answer:
ORI_ALONG_AXIS ORI_LOCAL
ORI_FRAME_MIRROR ORI_RELATIVE_TO
Defining u murker Iocution in terms of design vuriubIes
The model is parameterized, but you need to take it one step further. You should use design
variables to define the x, y, and z locations of the marker pnt7_ref.
To define u Iocution in terms of design vuriubIes:
1 Display the Table Editor.
2 Filter on markers:
s Select Filter.
s Set Scope to .sla.ground.
s Set Name Filter to *pnt*.
s Clear the selection of Adams ID.
s Select Location and Location and Ori. Components in Individual Columns.
3 Select Apply.
Workshop 4-Purumeterizing un isting ModeI,,,
Parametrics: Overview 89
4 Select the cell in the Loc_X column for pnt7_ref.
5 Right-click the input box at the top of the Table Editor, point to Parameterize, point to
Create Design Variable, and then select Real.
6 Repeat for the Loc_Y and Loc_Z cells, creating new design variables for each.
7 Select Apply.
8 Close the Table Editor.
9 Adjust the value of DV_3 to see what effect it has on the SLA geometry:
s From the Build menu, point to Design Variable, and then select Modify.
s From the Database Navigator, select DV_3.
s In the dialog box, set Standard Value to 500, and then select OK.
Notice that pnt7_ref moved upwards, and the geometry and constraint adjusted
parametrically.
Running simuIutions of different modeI configurutions
To run different simuIutions:
1 Display the toe angle measure, if necessary.
2 Simulate the model:
s End time: 1.0
s Steps: 50
3 Save the curve on the strip chart.
4 Change DV_3 to 480 and simulate again, and observe the effect on the toe angle
measurement.
Workshop 4-Purumeterizing un isting ModeI,,,
90 Parametrics: Overview
OptionuI tusks
1 Parameterize the outline geometry on ground so it adjusts as you move key points.
Tip: Use the f(x) tool to collapse ground geometry markers onto corresponding cylinder
center markers.
2 Parameterize the lower control arm (lca).
You should parameterize the lca geometry similar to how you parameterized the rest of the
model. In general, the steps are:
s Create design points at pnt1_ref and pnt2_ref.
s Use the F() tool to parameterize:
x Orientation of first long cylinder
x Orientation of second long cylinder
s Parameterize the following:
x Long cylinder lengths using DM.
x Short cylinder orientations using F() tool.
x Short cylinder locations using LOC_ALONG_LINE.
x LCA-to-spindle spherical joint using design points.
x LCA_ground_rev J marker orientation to lie in plane using F() tool with Same As/
Collapse options.
3 Preview what can be achieved with optimization in ADAMS/View:
s Start a new database and change directories to the completed subdirectory.
s Import the model mod_04_completed.cmd from the completed subdirectory.
This will build the fully parameterized SLA model.
s Import the command file prep_model_for_opt.cmd.
This file puts the SLA model into a configuration that needs to have its toe angle
optimized. It prepares the model for optimizing by defining design variables and an
optimization objective.
s Simulate using SIM_SCRIPT_1 to see the design performance of the SLA before
optimization.
Demonstrate the use of design points with simple link geometry. First create a few design points, then
draw the link showing how you want to pick each point when creating the link endpoints.
Workshop 4-Purumeterizing un isting ModeI,,,
Parametrics: Overview 91
s Plot Wheel Height vs. Toe Angle as shown in the figure below:
s Initiate the optimization by importing the command file run_opt.cmd.
You will have to wait a while as it will run several simulations.
s Use Reload Simulations tool in the ADAMS/Post Processor to update the plot with
the optimized design.
Read the readme.txt file for instructions on replay.
Workshop 4-Purumeterizing un isting ModeI,,,
92 Parametrics: Overview
Workshop 4-Purumeterizing un isting ModeI,,,
93
S
PARAMTRIZIM9 A MW MODL
Design the linkage on the hood mechanism so that the hood does not interfere
with the air filter when it is opened.
Bracket
Air
filter
Hood
Whut's in this moduIe:
s Construction Points to Parameterize a New
Model, 94
s Workshop 5Parameterizing a New Model, 95
94 Parameterizing a New Model
Construction Points to Purumeterize u Mew ModeI
Creute und Iocute uII construction points
s Using main toolbar
s Using the Table Editor.
s Creating them on ground (conventional method). You can, however, create them on
parts as well.
Note: For information on importing design points from a file, refer to the Knowledge
Base Article 8122 available at: http://support.adams.com/kb/faq.asp?ID=8122.
When creuting mechunism tie Iocution to construction points
s Ensure that the construction point is selected (either visually or by selecting with right
mouse button) when locating mechanism objects, such as geometry, joints, and
forces.
Parameterizing a New Model 95
This workshop takes about one hour to complete.
ProbIem stutement
You are the designer of the hood mechanism for a storage compartment. The new design of the
compartment has an air filter that needs to be changed frequently. You need to design the
linkage so that the hood does not interfere with the filter when it is opened. By building a
parametric model, you can study different design configurations.
.
9etting sturted
To import the modeI:
1 Start ADAMS/View from the mod_05_hood directory.
2 Import the basic model in hood_start.cmd.
Entire model can be built using a replay file on NT: mod_05_hood/rr/name_visi_via_dbnav.rr
XII I
II
III
IV
V VI VII
X
XI
VIII
IX
Bracket
Air
filter
Hood
Workshop -Purumeterizing u Mew ModeI
96 Parameterizing a New Model
Creuting design points
Now youll create four design points on ground. These points will be the basis on which you
build the rest of the model.
To creute the design points:
1 On the Main toolbox, double-click the Point tool . (Double-clicking the tool puts the
tool in repeat mode and lets you to create multiple points without selecting the tool again.)
2 In the Main toolbox container, ensure that the options are set to the defaults Add to Ground
and Dont Attach.
3 Click on the ADAMS/View window in four different places to create four different
points in roughly the locations shown above. Dont worry about placing the points
exactly because you will set their initial locations later.
4 Select the Select tool to turn off repeat mode.
To renume the points:
1 Using the mouse, draw a box around the four points you've just created to select them.
2 From the Edit menu, select Appearance, set Visibility and Name Visibility to On, and then
select OK.
Now you will see the points and their names.
3 Rename the points to POINT_1, POINT_2, POINT_3, and POINT_4. (To rename a point, right-
click the point, point to the name of the point, and then select Rename.)
You can use the Database Navigator to control steps 2 and 3 of the renaming procedure. To replay the file
on NT, use: mod_05_hood/rr/name_visi_via_dbnav.rr
E
D
A
C
B
Place your
points in
this area
Workshop -Purumeterizing u Mew ModeI,,,
Parameterizing a New Model 97
To set their initiuI Iocutions:
Using the Table Editor, set the point locations to the configuration for the initial design.
1 From the Tools menu, select Table Editor.
2 If necessary, at the bottom of the Table Editor, select Points.
3 In the cells, change the location of the points as shown in the table below.
4 Select OK.
The points should appear as shown below:
Initial Design Point Locations
Design point: Loc_X Loc_Y Loc_Z
ground.POINT_1 -2.3 -89.0 0.0
ground.POINT_2 111.0 -111.0 0.0
ground.POINT_3 40.0 -152.5 0.0
ground.POINT_4 166.0 -142.0 0.0
Workshop -Purumeterizing u Mew ModeI,,,
98 Parameterizing a New Model
Creuting Iinks
Now you will create links between the points. All the links will be of the same width and depth
so you can quickly create the links by setting the desired options and then setting the Link tool
to repeat mode.
To creute Iinks:
1 From the Main toolbox, select the Link tool .
2 In the container, set the options to:
s New Part
s Width: 2.0 cm
s Depth: 2.0 cm
Tip: Be sure to select the check boxes to ensure that ADAMS/View uses the width and
depth.
3 Double-click the Link tool to set repeat mode.
4 Create four links:
s Link from PT_B to POINT_4
s Link from PT_D to POINT_3
s Link from PT_E to POINT_2
s Link from PT_A to POINT_2
Note the following as you draw the links:
s As you select the points, ADAMS/View automatically parameterizes the link to the
design point locations.
s Therefore, when you select the locations, make sure you pick the actual points, not
other markers that might be located on top of the points.
s When prompted for a location, right-click the top of the point and choose the desired
point from the select list. This ensures that the point was selected.
Workshop -Purumeterizing u Mew ModeI,,,
Parameterizing a New Model 99
5 Select the Select tool to turn off repeat mode.
The links should appear as shown below:

Creuting connections between the Iinks
Now youll connect the links using revolute joints, inline joint primitives, and a spring-damper.
To creute revoIute goints:
1 From the Main toolbox, select the Revolute Joint tool .
2 In the container, set the options to:
s 1 Location
s Normal to Grid
3 Double-click the Revolute Joint tool to set repeat mode.
4 Create five revolute joints, taking care to select the correct design point:
s Revolute joint at PT_A (between PART_5 and ground)
s Revolute joint at PT_B (between PART_2 and ground)
s Revolute joint at PT_D (between PART_3 and PART_1)
s Revolute joint at PT_E (between PART_4 and PART_1)
s Revolute joint at POINT_1 (between PART_3 and PART_5)
5 Select the Select tool to turn off repeat mode.
Workshop -Purumeterizing u Mew ModeI,,,
100 Parameterizing a New Model
To creute inIine goint primitives:
You use the Joint palette to create inline joint primitives.
1 From the Build menu, select Joints.
2 Select the Inline Joint Primitive tool.
3 In the container, set the options to:
s 1 Location - Bodies Impl.
s Normal to Grid
4 Double-click the Joint Primitive tool to set repeat mode.
5 Create two inline joint primitives, again taking care to pick the correct design points:
s Inline joint primitive at POINT_2 (between PART_4 and PART_5)
s Inline joint primitive at POINT_3 (between PART_2 and PART_3)
6 Select the Select tool to turn off repeat mode.
To creute the spring-dumper:
1 From the Main toolbox, select the Translational Spring-damper tool .
2 Create the spring-damper from PT_C to marker on PART_2 at POINT_4.
Tip: Because both PT_C and POINT_4 are on ground, be sure to select the marker
belonging to PART_2 at POINT_4 (for example, MARKER_126) not POINT_4.
Workshop -Purumeterizing u Mew ModeI,,,
Parameterizing a New Model 101
To modify the spring-dumper purumeters:
1 Right-click the spring-damper, and then select Modify.
2 Set Stiffness Coefficient to (90(newton/mm)).
3 Set Damping Coefficient to (8(newton-sec/mm))
4 In the Preload text box, enter 0.
5 Select Length at Preload, and in the text box that appears, enter 250.
6 Select OK.
The connected hood should look like the following.
Initial Design
Workshop -Purumeterizing u Mew ModeI,,,
102 Parameterizing a New Model
Testing the purumeterizution
Now youll test the work that youve done so far. Youll verify that the model has only one
degree of freedom (DOF), and then simulate and animate it to see how the hood opens.
To test the purumeterizution:
1 From the Information tool stack on the status bar, select the Model Verify tool , and then
verify that the model has only one DOF. (If it doesnt, go back through the steps and see if
you can find your error.)
2 Simulate the model:
s End Time: 1.0
s Steps: 50
3 As the model simulates, confirm that the hood opens.
4 Does the hood interfere with the filter? _______ Yes _______ No
5 Animate as desired to observe the behavior of the hood mechanism.
6 Look at the strip chart of the measure FUNCTION_MEA_Y to see the displacement of the
hood marker relative to the marker representing the top surface. (If the strip chart is not
visible, from the Build menu, point to Measure, and then select Display.)
Workshop -Purumeterizing u Mew ModeI,,,
Parameterizing a New Model 103
Moving design points to see effect on design
Because you have parameterized the model to be dependent on the design point locations, you
can move the design points to see their effect on the design.
To move the design points to u second configurution:
1 Using the Table Editor, change the location of the points as shown in the table below.
Second Design
2 Simulate the model:
s End Time: 1.0
s Steps: 50
3 Does the hood interfere with the filter? _______ Yes _______ No
Point Locations for Second Design Configuration
Design point: Loc_X Loc_Y Loc_Z
ground.POINT_1 34.5 -91.3 0.0
ground.POINT_2 146.0 -109.0 0.0
ground.POINT_3 112.0 -150.0 0.0
ground.POINT_4 160.6 -147.0 0.0
Workshop -Purumeterizing u Mew ModeI,,,
104 Parameterizing a New Model
To move design points to u third design configurution:
1 Again using the Table Editor, change the location of the points as shown in the table
below.
Third Design
2 Simulate the model:
s End Time: 1.0
s Steps: 50
3 Does the hood interfere with the filter? _______ Yes _______ No
Point Locations for Third Design Configuration
Design point: Loc_X Loc_Y Loc_Z
ground.POINT_1 46.1 -98.4 0.0
ground.POINT_2 111.0 -111.0 0.0
ground.POINT_3 111.4 -146.4 0.0
ground.POINT_4 159.8 -142.3 0.0
Workshop -Purumeterizing u Mew ModeI,,,
Parameterizing a New Model 105
The following figure compares the fully opened hood for each design configuration:
Moving points using the move tooIs
s Move the points using the move tools to identify shortcomings in the way the model
was parameterized, such as the joint not at an intersection, joint not along line, both x
and y-values must be manipulated, as illustrated in the following figures:
Initial Design
Second Design Third Design
Joint_5 not at
*
intersection (*)
POINT_3 isnt along
line from PT_B
to POINT_4
Workshop -Purumeterizing u Mew ModeI,,,
106 Parameterizing a New Model
In this section, you learned how to parameterize a model using design points. In the next
module, you will learn how to create design variables, use them in your parametric model, and
perform a design study to see the effect that variables have on the hood motion.
Workshop -Purumeterizing u Mew ModeI,,,
107
6
DSI9M STUDY
Study the effect of changing link length in the hood mechanism.
Bracket
Air
filter
Hood
Whut's in this moduIe:
s Design Variables, 108
s Design Studies Overview, 111
s Specifying an Objective, 113
s Execution Display Settings, 114
s Output Settings, 118
s Setting Design Variables to Trial Values, 119
s Plotting, 120
s Workshop 6Performing a Design Study, 121
108 Design Study
Design VuriubIes
Overview
Feutures
Design Study 109
Design VuriubIes,,,
Overview
Design vuriubIes
s Define independent parameters that can be tied to objects.
s Organize the critical parameters of the design into a concise list of values that can be
easily reviewed and modified.
umpIe
You can create a design variable called cylinder_length to control the lengths of all three
cylinders as shown next:
Feutures
Cylinder_length = 150
Cylinder_length = 300
C
y
l
i
n
d
e
r
_
l
e
n
g
t
h
C
y
l
i
n
d
e
r
_
l
e
n
g
t
h
C
y
l
i
n
d
e
r
_
l
e
n
g
t
h
C
y
l
i
n
d
e
r
_
l
e
n
g
t
h
C
y
l
i
n
d
e
r
_
l
e
n
g
t
h
C
y
l
i
n
d
e
r
_
l
e
n
g
t
h
110 Design Study
Design VuriubIes,,,
Overview
Feutures
Runge
List of uIIowed vuIues
s Enter a discrete list of values to use in the design study.
Ignore Iist
s Lets you switch back and forth between using the range and the list of values, without
re-entering the list each time.
DefuuIt IeveIs
s If you specify a range only, ADAMS/View uses equally spaced levels across the
range. You specify the number of default levels.
s If you specify a list of values and Ignore List is not selected, ADAMS/View runs a
simulation using each value, ignoring the default levels specified.
Design Study 111
Design Studies Overview
TriuI und error method {munuuI iterutions}
Design study method {uutomuted iterutions}
Model
s Parts
s Joints
s Forces
Simulate
View results
Manually change
the variable
Loop is repeated
several times
Is the
design
optimal?
Completed
Yes
No
Design Variable
(V)
Objective (O)
Model
s Parts
s Joints
s Forces
Simulate
Results
automatically
generated
Plot O versus V
(for each iteration)
Tabular
report
Is this
the final
iteration?
(i=n)
Yes
Variable
changes
automatically
No
The loop goes through specified
number of iterations (i=1,n)
Model gets
updated
112 Design Study
Design Studies Overview,,,
Definition of u design study
s Varies a single design variable (V) across a range of values.
s Runs a simulation at each value.
s Reports the performance measure for each simulation.
From the resuIts generuted you cun determine
s The best value for V among the values simulated.
s The approximate design sensitivity of V (rate of change of performance measure with
respect to V).
Design Study 113
Specifying un Obgective
Meusures
s Select measure and specify whether to use the minimum, maximum, average, or last
simulated value of the measure as the objective value.
s You can easily reference the model outputs and perform many types of computations
on model outputs or other measures.
s You must specify the value of interest every time you perform a multi-run.
Obgective
s Objective objects are valuable when you want to do complex or multi-step
computations on model outputs.
s Use objective objects when measures are not flexible enough.
s Unlike using the measures method, objectives store the value of interest.
Defined viu:
s Measure
x Specify the characteristics directly (minimum, maximum, last value, and so
on).
s Result Set Component (new or existing)
x Specify the characteristics directly (minimum, maximum, average, and so on).
s ADAMS/View Function
x Specify the characteristics indirectly.
s ADAMS/View variable and macro
x Specify the characteristics indirectly.
114 Design Study
ecution DispIuy Settings
ModeI dispIuy updute
Strip churts
TubuIur output
Design Study 115
ecution DispIuy Settings,,,
ModeI dispIuy updute
When you want to update the model:
s Never
s At simulation end
x Most often used for multi-run simulations
s At every output step
s At every integration step
s At every iteration
Strip churts
TubuIur output
116 Design Study
ecution DispIuy Settings,,,
ModeI DispIuy Updute
Strip churts
Churt obgective
Depending on the type of parametric analysis, displays a strip chart of the following:
s Objective value versus variable value for a design study.
s Objective value versus trial for a DOE.
s Objective value versus iteration number for an optimization.
Churt design vuriubIes
Displays a strip chart of the following for each design variable:
s Variable value versus trial or iteration number.
Suve stripchurt curves
Clears all displayed measures at the beginning of the parametric analysis and automatically
saves the curve from each trial or iteration.
umpIe
TubuIur Output
Design Study 117
ecution DispIuy Settings,,,
ModeI dispIuy updute
Strip churts
TubuIur output
Automatically displays a tabular report at the end of the parametric simulation.
Note: You can use the Tabular Report tool to display this table at any time, write it to a
file, and control its format.
118 Design Study
Output Settings
IndividuuI versus muIti-run simuIution
s Both can save analyses
s Only individual can show ADAMS/Solver messages and save ADAMS/Solver files.
MuIti-run simuIution resuIts set
s Analogous format for DOE and optimization studies
s Structure for design studies:
Stop on errors
Stops the analyses if ADAMS/Solver encounters an error during the simulation.
Individual simulation settings
Multi-run simulation settings
Model
Multi-Run Results
Design_Study_Results
Trial Design Variable Objective
Design Study 119
Setting Design VuriubIes to TriuI VuIues
s Sets the design variable values to match those used in a specified trial, and updates
the model graphics to reflect the new values.
120 Design Study
PIotting
Meusure/obgective vuIue versus run
s Plots measure or objective versus the variable value, trial number, or iteration
number.
Meusure versus time
s Plots measure or objective versus time with a curve for each trial or iteration.
s Must have specified a measure or an objective that refers to a measure or result set
component (not a macro or function).
s Must have saved results from individual runs.
Design Study 121
This workshop takes about one hour to complete.
ProbIem stutement
In this workshop you will study the effect of changing link length in the hood mechanism. You
will learn how to create design variables, use them in your parametric model, and perform a
design study to see the effect that variables have on the hood motion.
In Workshop 5Parameterizing a New Model on page 95, you created a parametric model of
the hood mechanism by using design points. You learned that the model configuration could be
altered by moving the points to new locations. You also identified some shortcomings with that
approach. In this workshop you will define the parametric relationships in a different way so
that you eliminate the shortcomings and perform a design study.
9etting sturted
To import the modeI:
1 Start ADAMS/View from the mod_06_hood_DS directory.
2 Import the parameterized hood model, hood_2_start.cmd.
3 From the Settings menu, select Names.
4 In the Default Names dialog box, select Full Names.
5 Select OK.
XII I
II
III
IV
V VI VII
X
XI
VIII
IX
Bracket
Air
filter Hood
Workshop -Performing u Design Study
122 Design Study
Creuting design vuriubIes
In general, you need to identify the parameters in a model that you want to represent with design
variables. In deciding which model parameters would make good design variables youll find
there are a variety of choices you could make. In this example, youll consider a physical
characteristic, such as length, and an assembly characteristic, such as assembly angle.
You will define link lengths and assembly angles through design variables (L1, L2 and A1, A2
respectively). Then, you will prescribe the point locations of POINT_2, POINT_3, and POINT_4
so they are dictated by these design variables through the use of design-time expressions.
A2
A1
L1
L2
Workshop -Performing u Design Study,,,
Design Study 123
To creute design vuriubIes:
1 From the Build menu, point to Design Variable, and then select New. Create design variables
with parameters as shown in the table shown below.
Tip: You may find it easier to use the command line to create the variables.
2 From the Tools menu, select Table Editor.
3 At the bottom of the Table Editor, choose Points, and then select Filters.
The Points Table Editor Filters dialog box opens. Notice that several points are listed. Next,
reduce the set of points so only those of interest are shown.
4 From the Points Table Editor Filters dialog box, select Single Column for X,Y,Z and use a
Name Filter of *POI*.
5 Select OK.
The number of points listed has been reduced by the filtering operation.
Name Real_value Units
Absolute
Range
L1 215.0 length 200,250
L2 210.5 length 200,250
A1 -11.0 no_units -25,+10
A2 +4.8 no_units -10,+10
D1 0.77 no_units 0.15,0.85
Workshop -Performing u Design Study,,,
124 Design Study
Using cyIindricuI coordinutes
To use cyIindricuI coordinutes to redefine POIMT_Z reIutive to PT_A with
the design vuriubIes L1 und A1:
1 Select the location for POINT_2.
2 Right-click in the text box located at the top of the dialog box, point to Parameterize, and
then select Expression Builder.
3 In the Function Builder, replace the existing location with the following:
4 Select Evaluate to check the syntax.
5 Select OK.
The function has been sent to the Table Editor.
6 In the Table Editor, select OK.
The point location is now defined by the expression.
POINT_2
PT_A
A1
L1
Given:
Cylindrical coordinates (r,,z)
You know:
LOC_CYLINDRICAL(r,,z)
Here:
r=L1, =A1, z=0
Therefore:
LOC_CYLINDRICAL(L1,A1,0)
which is a 3x1 location array.
Then:
Express this array relative to
PT_A, by nesting it inside of
LOC_RELATIVE_TO. (See
highlighted step below.)
(LOC_RELATIVE_TO(LOC_CYLINDRICAL(L1, A1, 0),.hood1.ground.PT_A))
Workshop -Performing u Design Study,,,
Design Study 125
7 Using the procedure described in Using cylindrical coordinates on page 124 (or your own
method), redefine POINT_4 relative to PT_B using the design variables L2 and A2. Use the
following nested location expression:
(LOC_RELATIVE_TO(LOC_CYLINDRICAL(L2, A2, 0),.hood1.ground.PT_B))
8 Using the procedure described in Using cylindrical coordinates on page 124, redefine
POINT_3 to be located between PT_B and POINT_4 (as shown in figure below). Use D1 as a
multiplier for % offset from PT_B along line. Use the following location expression:
(LOC_ALONG_LINE(PT_B, POINT_4, D1*DM(PT_B,POINT_4) ))
Sweeping vuriubIes
Now that your design variables have been implemented in the points, you should make sure they
work properly. The usual way to do this is to modify them and change the real_value, testing
the upper and lower limits and values in between. To make this easier for you, we have provided
a custom macro and menu button (sweep) that will sweep a design variable between its upper
and lower limits.
To sweep vuriubIes:
1 Use the F2 key and import utils/DV_sweep/load_sweep_mac.cmd.
This loads the macro into your database and creates a custom menu button.
2 Use the custom menu button:
s From the Build menu, point to Design Variable, and then select Sweep.
0.85*DM
D1*DM
0.15*DM
PT_B POINT_4
DM
Workshop -Performing u Design Study,,,
126 Design Study
3 In the Variable Sweep dialog box, sweep D1 to see how it works.
4 Sweep A1, noticing that POINT_1 isnt staying on the point of intersection between the
links. You will fix that problem in the next section.
5 Sweep the remaining variables, L1, L2, and A2, to confirm that theyre being used
correctly.
Locuting u point ut un intersection of two Iines
As you observed in Workshop 5Parameterizing a New Model on page 95, one of the
shortcomings of parameterizing by points only was that interdependencies werent captured. In
the hood mechanism you saw that POINT_1 should lie at the intersection of the lines PT_A-to-
POINT_2 and PT_D-to-POINT_3. You can calculate this intersection mathematically and store
it in an ADAMS/View user-written function. This function can then be used to define the
location of POINT_1.
To Iocute u point ut un intersection:
1 Change the appearance of POINT_1 to blue so that its easier to see.
2 The algebraic mathematics needed to find the intersection of two lines from four points
are rather involved. Using a text editor, review the contents of find_intersection.cmd (in
the Misc folder) to see the syntax for creating the user-written interpreted function,
INT_PT.
3 How many input arguments are used? 2 3 4
4 How many output values are returned? 2 3 4
5 Would you like to type the lengthy expression text by hand every time you wanted to
calculate an intersection? ____Yes ____No
Note: For information on finding the intersection point of two lines and parameterizing
its location, refer to the Knowledge Base Article 8901, available at:
http://support.adams.com/kb/faq.asp?ID=kb8901.dasp
6 Import the INT_PT user-written interpreted function to calculate the intersection of two
lines from four points in a plane.
Tip: Use the F2 key to quickly import the file find_intersection.cmd (in the Misc folder).
Workshop -Performing u Design Study,,,
Design Study 127
7 Set POINT_1 to lie at intersection of the lines PT_A-to-POINT_2 and PT_D-to-POINT_3 by using
the INT_PT user-written interpreted function. Do so by using the following location
expression syntax to define the POINT_1 location:
(INT_PT(PT_A, POINT_2, PT_D, POINT_3))
8 Test the behavior of the INT_PT function by modifying a design variable and observing
whether or not POINT_1 updates parametrically. Use Sweep Variable and sweep D1.
Notice that the Intersection function (INT_PT) works as desired and all interdependencies
are correctly maintained.
Defining u meusure to study
Soon you will run design studies for several of the design variables. A little later in the course,
you will optimize the model using all the design variables. Both of these analysis types are
known as multi-run simulations, and their command language requires a measure or an
objective as one of the input parameters.
Remember that you want to design the linkage so the hood never touches the filter as it is
opened. Therefore, a measure of that is what you want to study in the design study. As you recall
from Workshop 5Parameterizing a New Model on page 95, there was a pre-existing measure
FUNCTION_MEA_Y that measured the distance from a marker on the rear of the hood to the top
surface of the filter. When the value of that measure became negative, you knew that the hood
was penetrating the filter and was, therefore, an unacceptable linkage design.
Workshop -Performing u Design Study,,,
128 Design Study
As you become more familiar with optimization objectives and constraints, you will learn that
the sign of a measure (+ or -) has special meaning. For example, if an optimization constraint is
positive, then it has been violated. If it is negative, it has not been violated and the design is
considered acceptable. To begin thinking along those lines, modify the FUNCTION_MEA_Y so
that a positive value of the measure indicates that the hood marker has interfered with the filters
top surface. Conversely, if the measure stays negative throughout the operation cycle, it means
that its an acceptable linkage design.
To define u meusure to study:
1 Modify FUNCTION_MEA_Y.
Negate the DY function expression so it appears like this:
-DY(.hood1.PART_1.MARKER_rear, .hood1.ground.top_surf, .hood1.ground.top_surf)
2 If the strip chart is not already displayed, display it.
Note: Later in Workshop 8Optimization on page 158, you will use this measure as a
design constraint in an optimization. Now that youve negated it, its ready to use.
3 Run a baseline simulation (1 sec/50 steps) from the Main Toolbox and review how the
mechanism operates and what the measure looks like.
4 Does the measure stay negative throughout the simulation?_____ Yes _____ No
i
y
j
x
UNACCEPTABLE
The hood should
not interfere with
the filter at any
time during the
simulation.
FUNCTION_MEA_Y=DY(i,j,j)
Workshop -Performing u Design Study,,,
Design Study 129
Performing u design study
Here you will study the effect of L1 on the hood opening behavior by performing a design study.
To perform u design study:
1 From the Simulate menu, select Design Evaluation, and complete the Design Evaluation Tools
dialog box as follows:
s Select Design Study radio button
s Simulation Script: Last_sim
s Study a: Maximum of
s Measure: FUNCTION_MEA_Y
s Design Variable: L1
s Default Levels: 5
2 Select Start to initiate the design study.
3 When the design study has finished, generate a tabular summary report of the design
study by clicking the icon at the bottom of the dialog box.
4 Briefly review its contents.
5 Study the effect of A1 by running a design study.
6 Which trial(s) in this design study had some strange or unexpected linkage behavior?
______________________________________________________________________
Workshop -Performing u Design Study,,,
130 Design Study
7 What was the value of A1 for that trial? ______________________________________
8 Reduce the lower bound for variable A1 so the absolute range is: -15, +10.
Now youll run the design study of A1 again, using the new range. First you will make some
settings that will allow the multi-run simulations to run faster, while still giving you visual
feedback of the opened hood for each design configuration.
To run the design study uguin:
1 In the Design Evaluation Tools dialog box, select the Display button.
The Simulation Settings dialog box opens.
2 Complete the dialog box as follows:
s Execution Display
s Model Display Update: At Simulation End
s Status Bar Monitor Update: At Every Output Step
s Chart Objective
s Save strip chart curves
s Show tabular report
3 Run another design study of A1.
4 Did the study exercise A1 through its new range (-15 to 10)? _____ Yes _____ No
5 Does the range on the variable seem well-bounded now? Why or why not?
_____________________________________________________________________
_____________________________________________________________________
6 In which trial(s) did the objective stay negative (that is, the hood didnt touch the filter)?
___________________
7 Export the model in command file format as after_DS.cmd.
Step 7: There is a known bug where lengthy user-written interpreted functions are not written out cor-
rectly (cr24536). You will encounter errors if you try to read it back in. Workaround: replace function cre-
ate text with that from find_intersection.cmd.
Workshop -Performing u Design Study,,,
Design Study 131
Setting the design vuriubIe to vuIues used in u triuI
Here you will run the simulation using the value obtained from the previous design study.
To set the design vuriubIe:
1 Using the Set Variables tool set the design variable A1 to the value from the trial where
the objective was the maximum negative value (that is, trial 2).
2 Run an individual simulation and animate the results.
3 Save the database.
4 If time permits, complete some of the optional tasks.
OptionuI tusks
1 Run more design studies.
s Set the output settings to Save Analyses for both individual simulations and multi-run
simulations. Perform a design study and select the Plot Results tool from the
dialog box to generate the plots. Review the various plots that are created.
s If you run an additional design study, will it overwrite the saved analyses or create a
series of new ones with similar naming structure?
__________________________________________________________________
s Do you know how to delete the analyses from the database? Please explain.
__________________________________________________________________
2 Experiment with sliders.
s Import the file utils/DV_live_slider/hood_variable_control.cmd. This displays a customized
dialog box with sliders to control the values of the design variables. Experiment with
different settings and run simulations.
3 Run design studies of design variables D1, L2, A2.
s Run design studies of the remaining variables (D1, L2, A2). See how the mechanism
behaves as the design variables sweep throughout their ranges.
s Do the design variable ranges seem well bounded? ___Yes ___No
Slider behavior is somewhat problematic in version 11.0. See CR 25048 for details.
Workshop -Performing u Design Study,,,
132 Design Study
4 Run design study using list of values.
s Modify one of the design variables so that it is defined by a list of values. Run a
design study of that variable and review the summary report to see if it actually used
the list of values you provided.
s Was the list of values used? ____Yes ___No
s Select Allow Design Study to ignore list on the design variable modify dialog box. Run
a design study again.
s Did it ignore your list of values? ____Yes ___No
5 Answer the following questions:
s Do you think it's possible to study more than one measure at a time? ____Yes ___No
Try it.
s How about studying more than one objective at a time. Do you think that would
work? _____ Yes _____ No
Try it.
Tip: Make two objectives, average value and minimum absolute value.
Step 4: There is a known issue where warning pertaining to the list of values may be
reported incorrectly (CR24535). For example, the warning will be in radians when the
user would expect degrees.
Workshop -Performing u Design Study,,,
133
7
DSI9M OF XPRIMMTS
Simulate the motion of a one-legged robot, referred to as the unipod.
Whut's in this moduIe:
s Design of Experiments (DOE) Overview, 134
s Trials Defined By, 135
s DOE Process in ADAMS/View, 139
s Workshop 7Design of Experiments, 140
134 Design of Experiments
Design of periments {DO} Overview
Whut is DO?
s DOE is a collection of procedures and statistical tools for planning experiments and
analyzing the results.
s DOE shows the effects of varying several design variables simultaneously.
Types
s Screening: Identifies which factors and combinations of factors most affect the
behavior of the system.
s Robust design: Methodology developed by Dr. Genichi Taguchi for improving
quality by controlling the effects of variations in a system.
s Response surface methods (RSM): Fit polynomials to the results of the runs, which
gives you a easy-to-use approximation of your systems behavior.
Design of Experiments 135
TriuIs Defined y
uiIt-in technique
Direct input
FiIe input
136 Design of Experiments
TriuIs Defined y,,,
uiIt-in technique
DO technique
s Full Factorial: Simulates every possible combination of levels.
Example: 2 variables (factors) with 3 levels each = 9 simulations.
s User-defined Algorithms: Run simulations based on algorithms you define.
Direct input
FiIe input
Design of Experiments 137
TriuIs Defined y,,,
uiIt-in technique
Direct input
s Does not directly specify factor values.
s Specifies indexes to the levels for each factor. The indexes center on zero. This means
that for a two-level factor, the only possible values are -1 and +1; for three-levels, -1,
0 and +1; for four-levels, -2, -1, +1, +2; and so on.
umpIe
s DOE setup:
s Desired test:
s Corresponding design matrix:
0 +1
-1 0
+1 -1
+1 +1
FiIe input
Factors Levels Corresponding Index
Factor 1 9, 10, 11 -1, 0, +1
Factor 2 85, 90, 95 -1, 0, +1
Run Factor 1 Factor 2
1 10 95
2 9 90
3 11 85
4 11 95
138 Design of Experiments
TriuIs Defined y,,,
uiIt-in technique
Direct input
FiIe input-
s Specify the name of the file containing the trial matrix.
s First line of file must contain:
x number of factors
x number of levels
x number of runs
See user.dat in the mod_07_unipod_DOE directory for an example of file input.
Design of Experiments 139
DO Process in ADAMS/View
The following is the DOE process in ADAMS/View:
1 Start with a parametric ADAMS/View model.
2 Add list of values to the design variables.
3 Define an objective function (that is, the quantity you want to measure).
4 Generate or input the design matrix.
5 Execute runs.
6 Tabulate and output variable and objective values.
The DOE capabilities in ADAMS/View are somewhat limited. You can, however, use
ADAMS/Insight to perform more advanced functions. Refer to the ADAMS/Insight
documentation for more information.
140 Design of Experiments
This workshop takes about one hour to complete.
ProbIem stutement
In this workshop you will simulate the motion of a one-legged robot, referred to as a unipod.
This unipod has a triangular truss structure that has been parameterized using points whose
locations are defined by eight design variables. The unipod is able to move through a small force
actuator that turns on and off repeatedly, applying 650 N of force during its extension. A spring
allows the return stroke of this leg. Your goal is to make the robot walk toward the semi-circular
arc located at the edge of the platform in such a way that when the simulation is complete, its
base is contained within the boundary of the semicircle.
You will learn how to run Design of Experiment (DOE) analyses to identify which design
variables are significant. This screening process will result in a good starting point for an
optimization study.
XII I
II
III
IV
V VI VII
X
XI
VIII
IX
Workshop 7-Design of periments
Design of Experiments 141
9etting sturted
To get sturted:
1 Start ADAMS/View from the mod_07_unipod_DOE directory.
2 Import the baseline model, unipod_start.cmd.
3 Move the strip chart aside so you can see the unipod.
4 From the Settings menu, select Names.
5 In the Default Names dialog box, select Full Names.
6 Select OK.
7 Simulate the model for 1 second using the script SIM_SHORT.
8 Animate as needed to answer the following question:
Does it walk? _____ Yes _____ No
Workshop 7-Design of periments,,,
142 Design of Experiments
Figure 1. Unipod views
Pt4_y
Pt3_x
Pt2_x
FRONT VIEW
w1 and w2 represent weighting factors. The
smaller the value, the less pull the
corresponding ball has at the vertex.
When w1=w2=0.333, the foot is centered in
the lower triangle as shown by the solid
black circle. Each ball has equal weighting.
When w1=w2=0.15, the foot is biased
toward ball 3 as shown by the x. These two
variables are coupled to each other.
2
1
3
TOP VIEW
Pt2_z
Pt4_z
Pt3_z
RIGHT VIEW
x
Workshop 7-Design of periments,,,
Design of Experiments 143
Performing u design study
To perform u design study:
1 Review the eight design parameters by studying Figure 1 on page 142, and sweeping the
design variables with the Sweep Variable customized menu button
s From the Build menu, point to Design Variables, and then select Sweep.
Tip: Use 15 frames.
2 Circle the two parameters that would have the biggest effect on making the unipod walk:
3 Perform a five-level design study of pt4_z:
s Simulation Script: SIM_SHORT
s Study a: Minimum of
s Measure: DM_TO_ZONE
s Design Variable: pt4_z
s Default Levels: 5
4 Create a tabular report of the results. Save the file as U_DS_summary.txt.
5 Which trial made it walk closer to its destination than the others? Write the trial number
and the value here: ________, _______
6 Save the design study multi-run results set:
s Use the Save Last Results button to open the Save Design Evaluation Results
dialog box.
s Name the design study U_DS.
7 Set the value of pt4_z to that of trial 5:
s From the Design Evaluation Tools dialog box, select the Set Variables button to
open the Update Design Variables dialog box.
s Enter 5.
pt4_y pt2_x pt3_x w1
pt4_z pt2_z pt3_z w2

Workshop 7-Design of periments,,,


144 Design of Experiments
SimuIuting the unipod
You used a short simulation to get the unipod moving. Now you will see how well it travels in
a longer simulation run.
To run u simuIution:
1 Run a 5-second simulation using SIM_LONG.
2 Run an animation using trace markers (.model_1.PART_2.MAR_BALL_CTR_1, for example) to
better see the path it has taken.
3 Describe, in general, the nature of the path that the unipod takes.
________________________________________________________________
________________________________________________________________
Performing u DO of w1 und wZ
Now youll study the effect variables w1 and w2 have on the measure DM_TO_ZONE.
DM_TO_ZONE is the distance magnitude from the center-of-mass of PART_2 to the
ground.ZONE_MARKER. Basically, it measures if the unipod is walking toward to desired zone
or away from it.
To perform u DO:
1 To improve simulation speed, turn off the execution graphics, and set Model Update to At
Simulation End.
2 Set up the DOE:
s Simulation Script: SIM_LONG
s Study a: Minimum of
s Measure: DM_TO_ZONE
s Design Variables: w1, w2
s Default Levels: 4
s DOE Technique: Full Factorial (16 runs)
Tip: Use the Check Variables, Guess # of Runs button to compute number of runs required.
3 Save the DOE multi-run results set as U_DOE_w1w2.
Workshop 7-Design of periments,,,
Design of Experiments 145
4 Create a tabular report of results named U_DOE_w1w2.txt.
5 In which trial did the unipod walk the farthest? _______
6 Write the corresponding values of w1 and w2. __________, __________
7 Set the w1 and w2 variables to the values from that trial.
Performing u DO by direct input
Now youll run DOEs of design variables pt2_x and pt2_z.
To perform u DO by direct input:
1 Generate the list of acceptable values for pt2_x.
s From the Build menu, point to Design Variable, and then select Modify.
s Select pt2_x from the Database Navigator.
s In the Modify Design Variable dialog box:
x Select List of allowed values.
x Select Generate.
x In the Total Number of Values text box, enter 4.
x Select Generate new list.
x Select OK.
The values should be -100.0, -33.3333333333, 33.3333333333, and 100.0.
2 Repeat the procedure in Step 1 to generate the list of acceptable values for pt2_z:
The values should be -316.506, -294.3373333333, -272.1686666667, and -250.0.
Ignore the error that current value is not one of the allowed values.
Workshop 7-Design of periments,,,
146 Design of Experiments
3 Perform a DOE of pt2_x and pt2_z.
s Simulation Script: SIM_LONG
s Study a: Minimum of
s Measure: DM_TO_ZONE
s Design Variables: pt2_x, pt2_z
s Default levels: 4
s Trials defined by: Direct Input
s Number of Trials: 8
s Trial Matrix:
4 Save the DOE multi-run results set as U_DOE_pt2.
5 Create a tabular report of the results named U_DOE_pt2.txt.
6 In which trial did the unipod walk the farthest? _________
7 Write the corresponding values of pt2_x and pt2_z. _______, _______
8 Set the pt2_x and pt2_z variables to the values from that trial.
9 Set output settings to Save Solver Files as after_DOE_screen.
10 Turn execution graphics back on.
11 Simulate the model again using SIM_LONG to review its performance after completing the
DOE screening process.
Use trace markers (.model_1.PART_2.MAR_BALL_CTR_1, for example) to see the path
when you animate.

1, -2
1, -1
1, +1
1, +2
2, -2
2, -1
2, +1
2, +2
Workshop 7-Design of periments,,,
Design of Experiments 147
12 Describe, in general, the nature of the path that the unipod takes.
________________________________________________________________
13 Is the unipod fully contained inside the blue semi-circle arc? ____ Yes ____ No
14 Does this seem like a good starting point for an optimization? ____ Yes ____ No
15 Turn off the Saving of Solver files and set Model Display Update to At simulation end so as to
maximize the speed of the optimization multi-run simulations.
16 Save the model database as after_DOE_screen.bin.
OptionuI tusks
Optimizution 1-
1 Using the results from the DOE screen as a starting point, optimize the design using all
eight design variables (pt2_x, pt2_z, pt3_x, pt3_z, pt4_y, pt4_z, w1, w2) and the optimization
constraints OPT_CNSTR_1, OPT_CNSTR_2, OPT_CNSTR_3.
s Simulation Script: SIM_LONG
s Study a: Last Value of
s Measure: DM_TO_ZONE
s Goal: Minimize Des. Meas./Objective
2 Save the optimization multi-run result set as U_OPT_all.
3 Create a tabular report of results named U_OPT_all.txt.
Optimizution Z-
s Using the best solution from the initial design study as a starting point (Trial 5), see if
the solution can be found without the DOE screen, using only an unconstrained
optimization:
x Simulation Script: SIM_LONG
x Study a: Minimum of
x Measure: DM_TO_ZONE
x Design Variables: pt2_x, pt2_z, pt3_x, pt3_z, pt4_y, pt4_z, w1, w2
x Goal: Minimize Des. Meas./Objective
May encounter warning message.
Have them run optimization 1 before lunch as it may take a while.
Computing gradients/performing line search. Iteration: 3 Pass: 1
Objective 1 = 3.902882e+002
Constraint 1 = -5.046156e+002
Constraint 2 = -4.763955e+002
Constraint 3 = -2.728929e+001
The optimization has terminated.
Total optimization analysis calls: 24
Have them run optimization 2 at night because it takes a long time.
Computing gradients/performing line search. Iteration: 8 Pass: 1
Objective 1 = 6.974371e+001
The optimization has terminated.
Total optimization analysis calls: 76
Workshop 7-Design of periments,,,
148 Design of Experiments
Workshop 7-Design of periments,,,
149
8
OPTIMIZATIOM
Optimize the design of the hood mechanism while minimizing the material
cost of the linkage and satisfying three design constraints.
Whut's in this moduIe:
s Optimization Overview, 150
s Constraints, 151
s Optimization Settings, 152
s Workshop 8Optimization, 158
150 Optimization
Optimizution Overview
Optimization adjusts design variables to minimize or maximize a particular aspect of your
models performance.
It involves:
s Determining which objective function you want to minimize or maximize,
s Selecting the design variables you want to change, and
s Specifying the constraint functions that must be specified.
Examples of objectives you might want to optimize are:
s Execution time
s Energy (effort) required
s Total material costs
s Comfort
s Stability
Optimization 151
Construints
Design vuriubIes
s Purpose and setup for optimization studies is the same as for design studies and
DOEs.
s By default, ADAMS/View uses the design variable lower and upper limit (that is, the
range) as constraints for optimization studies.
s You can tell ADAMS/View to Allow Optimization to ignore range.
Construint functions
s Setup is analogous to Objective Functions.
s During optimization study, ADAMS/View ensure that evaluated constraint functions
are always negative, and therefore not violated.
152 Optimization
Optimizution Settings
AIgorithm types
Convergence toIerunce
Iterutions
Differencing
Debugging
AIgorithm types
Optimization 153
Optimizution Settings,,,
AIgorithm types
s DOT1: Use DOT with BFGS (Broydon-Fletcher-Goldfarb-Shanno) for unconstrained
problems; use DOT with MMFD (Modified Method of Feasible Directions) for
constrained problems.
s DOT2: Use DOT with FR (Fletcher-Reeves) for unconstrained problems; use DOT
with SLP (Sequential Linear Programming) for constrained problems.
s DOT3: Use DOT with FR for unconstrained problems; use DOT with SQP
(Sequential Quadratic Programming) for constrained problems.
s OPTDES_GRG: Uses OPTDES Generalized Reduced Gradient.
s OPTDES_SQP: Uses OPTDES Sequential Quadratic Programming.
For more information on algorithms, refer to the paper, Numerical Optimization, which can be
found on the course CD in papers/UC950004.PDF.
Convergence toIerunce
Iterutions
Differencing
Debugging
Provided with ADAMS/View
Provided by Design
Synthesis, Inc.
User-written algorithms
linked to ADAMS/View
DOT1
DOT2
DOT3
OPTDES-GRG
OPTDES-SQP
User1, User2, User3
154 Optimization
Optimizution Settings,,,
AIgorithm types
Convergence toIerunce
s The limit below which subsequent differences of the objective must fall before an
optimization is considered successful.
s Satisfied when:
ABS(objective[new] - objective[new-1]) < convergence tolerance
Iterutions
Differencing
Debugging
Optimization 155
Optimizution Settings,,,
AIgorithm types
Convergence toIerunce
Iterutions
Muimum
s Tells the optimizer algorithm how many iterations it should take before it admits
failure.
RescuIe
s The number of iterations after which the design variable values are rescaled.
s If you set the value to -1, scaling is turned off.
Differencing
Debugging
156 Optimization
Optimizution Settings,,,
AIgorithm types
Convergence toIerunce
Iterutions
Differencing
Technique
s Controls how the optimizer computes gradients for the design functions.
Increment
s Specifies the size of the increment to use when performing finite differencing to
compute gradients.
Debugging
More accurate approximating
More susceptible to random
variations
Helps minimize the effects of
variations.
Gives less accurate gradients.
+
-
+
-
Smaller Increments
Larger Increments
Optimization 157
Optimizution Settings,,,
AIgorithm types
Convergence toIerunce
Iterutions
Differencing
Debugging-
s Sends detailed optimizer diagnostics to the window that launched ADAMS/View.
For more information on optimization, refer to the ADAMS Version 8 Optimization white paper
(in .pdf format) and examples that can be found on the course CD in the old_v8_opt directory.
Debugging output is written to fort.80 file on NT.
158 Optimization
This workshop takes about one hour to complete.
ProbIem stutement
In this workshop, you will optimize the design of the hood mechanism. The goal is to minimize
the material cost of the linkage while satisfying the following three design constraints:
s Inclination angle of 55 degrees when the hood is fully open
s Filter is accessible from above when the hood is open
s Hood doesnt interfere with the filter throughout the entire range of motion.
You will learn how to create a design objective and design constraints, and how to use them in
your parametric model to optimize the design.
9etting sturted
To import the modeI:
1 Start ADAMS/View from the mod_08_hood_OPT directory.
2 Import the hood model that has been parameterized with design variables,
hood_3_start.cmd.
XII I
II
III
IV
V VI VII
X
XI
VIII
IX
Workshop -Optimizution
Optimization 159
3 From the Settings menu, select Names.
4 In the Default Names dialog box, select Full Names.
5 Select OK.
Creuting design construints
In Workshop 6Performing a Design Study, you performed a design study of the parametric
hood mechanism. You learned that you could study the effect of one design parameter in
isolation. Optimization offers many advantages over a design study. For example:
s Multiple design parameters can be changed simultaneously.
s Various design criteria can be monitored and maintained.
s An objective can be minimized (or maximized) automatically to find an optimal
solution.
Each design constraint creates an inequality relationship or criteria. The optimization algorithm
tries to keep the value of the constraint less than or equal to zero. You need to construct your
constraints in such a way that positive values represent undesirable designs, and negative or zero
values represent acceptable designs (or satisfied criteria).
To creute the first construint:
The first design criteria is to have the hood open to a maximum inclination angle of 55 degrees.
You will create a design constraint to monitor the angle, making sure its satisfied during the
optimization.
Here you find the current inclination angle of the hood relative to ground using the AZ function
and then subtract it from the desired angle. This will result in a positive value for the measure
when the angle is less than 55 degrees. This design constraint will be used in the optimization.
1 Create a function measure.
s From the Build menu, point to Measure, point to Function, and then select New.
s Specify the following:
x Measure Name: FUNCTION_MEA_AZ
x Function: 55d - AZ(.hood1.PART_1.MARKER_front)
x Units: angle
Workshop -Optimizution,,,
160 Optimization
2 Define a design constraint using the measure you just created.
s From the Simulate menu, point to Design Constraint, and then select New.
s Specify the following:
x Constraint Name: OPT_CONSTRAINT_1
x Measure: FUNCTION_MEA_AZ
x Design Constraints value: value at simulation end
The output characteristic to monitor is the last value of this measure; that is, when the hood
it fully open.
To creute the second construint:
The second design criteria is to design the hood linkage such that the air filter is easily accessible
from above when the hood is fully open. One way to achieve this goal is to have the rearward
end of the hood move forward as the hood opens, ending at 50 mm offset from the starting
configuration.
Here you find the current distance between PART_1.MARKER_rear and ground.top_surf
relative to ground using the DX function and then subtract it from the desired offset distance of
50 mm. This results in a positive value for the measure when the distance is less than 50 mm.
Again, this will be used as a design constraint in the optimization. When the value of the
constraint is negative, the criteria is satisfied.
Want access
from above
func = 50 - DX(i,j,j)
i
function
- negative side
j
y
x
50
positive side +
Workshop -Optimizution,,,
Optimization 161
1 Create a function measure:
s Measure Name: FUNCTION_MEA_DX
s Function: 50-DX(PART_1.MARKER_rear, ground.top_surf, ground.top_surf)
s Units: length
2 Define a design constraint using the measure you just created:
s Constraint Name: OPT_CONSTRAINT_2
s Measure: FUNCTION_MEA_DX
s Design Constraints value: value at simulation end
The last value of this distance measure is what you want to monitor using this constraint.
To creute the third construint:
The third optimization constraint will be based on the measure you created for the design study
in Workshop 6Performing a Design Study on page 121, FUNCTION_MEA_Y. Remember that
you already negated the value of the measure, so any positive values indicated that the hood was
interfering with the filter. Refer back to the figure on page 128 see what that measure calculates.
1 Define a design constraint using the maximum value of the measure:
s Constraint Name: OPT_CONSTRAINT_3
s Measure: FUNCTION_MEA_Y
s Design Constraints value: maximum value during simulation
vuIuuting the construints
After youve created the constraints, you need to test and evaluate them.
To test the construints:
1 Run a 1 second/50 step simulation using the Main Toolbox.
2 Animate the optimized design using trace markers for: PART_1.MARKER_front and
PART_1.MARKER_rear.
Workshop -Optimizution,,,
162 Optimization
To evuIuute the construints:
1 Press F3 to display the Command Window.
This is where ADAMS/View writes the values of the evaluated constraints.
2 From the Tools menu, select Command Navigator.
3 Select optimize, select constraint, and then select evaluate.
4 Browse the Constraint Name text box and select all three of the constraints you just created.
5 In the Analysis Name text box, point to Guesses, and then select Last_Run.
6 Select Apply.
7 Look in the Command Window to see the approximate values of the constraints.
.hood1.OPT_CONSTRAINT_1(.hood1.Last_Run) 18.18 (deg)
.hood1.OPT_CONSTRAINT_2(.hood1.Last_Run) 43.98 (mm)
.hood1.OPT_CONSTRAINT_3(.hood1.Last_Run) -0.12 (mm)
8 Circle the design criteria that are not satisfied in the given design.
A an inclination angle of 55 degrees
B filter is accessible from above
C hood doesnt interfere with filter
The constraints have been created and evaluated. Now you need to create the optimization
objective.
Workshop -Optimizution,,,
Optimization 163
Creuting the optimizution obgective
You want to optimize the mechanism for minimum material cost. The cost of the material is
proportional to the overall mass of the link parts. You can create a measure that sums the total
mass of the linkage and multiply this by a scale factor to approximate the overall cost. Using a
computed measure, sum the part masses (as accessed with the .mass component value) and
multiply by a scale factor of 10.
To creute u computed meusure:
1 From the Build menu, point to Measure, point to Computed, and then select New.
2 In the Measure Name text box, enter COMP_MEA_COST.
3 In the Create or Modify a Computed Measure text box, enter:
(10*(PART_2.mass + PART_3.mass + PART_4.mass + PART_5.mass))
Note: You could create an objective using procedures similar to those used to create the
constraints, but instead youll just use the measure itself during the optimization,
because its easier.
Optimizing the design
Now you will perform a multi-run simulation known as an optimization.
To run un optimizution:
1 Set execution graphics to update at the end.
This will let the simulation run quickly while still giving you feedback about the opened
hood for each design configuration.
2 Submit a baseline analysis:
s End Time: 1
s Steps: 50
Youll use this script later for the optimization.
Workshop -Optimizution,,,
164 Optimization
3 Submit the first constrained optimization to minimize cost, using the design variables L1,
A1, L2, A2, and D1.
s From the Simulate menu, select Design Evaluation.
s Select Optimization.
s Specify the following:
x Model: .hood1
x Simulation Script: .hood1.Last_Sim
x Study a: Last value of
x Measure: .hood1.COMP_MEA_COST
x Design Variables: A1,A2,D1,L1,L2
x Goal: Minimize Des. Meas./Objective
x Constraints: OPT_CONSTRAINT_1,OPT_CONSTRAINT_2,OPT_CONSTRAINT_3
s Select Start to begin the optimization.
Your Command Window will update with the information from the optimizer.
4 When the optimization is completed, animate the optimized design with trace markers for
PART_1.MARKER_front and PART_1.MARKER_rear.
5 Save the optimization results using the Save Results tool and write a summary table
named opt_results_1.txt. Briefly review its contents.
6 Write down the cost of the optimized design and the angle of the hood.
$______________, ________________
7 Look in the Command Window and answer the following questions:
s Were each of the constraints satisfied? ____ Yes ____ No
s What is the total number of calls made by the optimizer? _______________________
8 Using a text editor, review the file, opt_results_1.txt.
9 Which of the design variables was driven to an upper or lower limit of its range?
_____________________________________________________________________
It doesnt matter what you set in the Study a option menu because the mass doesnt change during the
simulation.
Workshop -Optimizution,,,
Optimization 165
Ignoring the runge of u vuriubIe during optimizution
To ignore the vuriubIe runge:
1 Modify design variable L1 and select Allow Optimization to ignore range.
Make sure that Units is set to length.
2 Perform another optimization.
Note: Warning messages will be issued when L1 is pushed beyond the range.
3 Save the results in a file named, opt_results_2.txt.
4 Have all of the constraints been satisfied? _____ Yes _____No
5 What is the cost of this design? $_____________________________________________
Using u toIerunce bund on u construint
Perhaps you can save some cost by being less strict about the fully-open hood angle. Consider
what design optimum you might find if you said the inclination angle could be 50 +/-5 degrees.
To use u toIerunce bund:
1 Create a design variable A_tolerance that represents the loosening of the inclination angle
design constraint:
s Name: .hood1.A_tolerance
s Units: angle
s Real value: 55.0
s Range: 45.0, 55.0
s Unselect Allow Optimization to ignore range
Consider this a change in the design specification of the inclination angle so that it has a
tolerance band of 50 +/-5 degrees.
2 Modify the measure:
s Measure Name = .hood1.FUNCTION_MEA_AZ
s Function = .hood1.A_tolerance-AZ(.hood1.PART_1.MARKER_front)
s Units = angle
When A_tolerance is included in the list of variables for the optimization, it allows the
constraint to be relaxed, as needed, to find a more optimal solution.
Workshop -Optimizution,,,
166 Optimization
3 Submit a second constrained optimization to minimize cost, using the design variables:
L1, A1, L2, A2, and D1. This time, relax the angle constraint by including the design
variable A_tolerance:
s Model: .hood1
s Simulation Script: .hood1.Last_Sim
s Study a: Last value of
s Measure: .hood1.COMP_MEA_COST
s Design Variables: A1,A2,A_tolerance,D1,L1,L2
s Goal: Minimize Des. Meas./Objective
s Constraints: OPT_CONSTRAINT_1,OPT_CONSTRAINT_2,OPT_CONSTRAINT_3
4 Save the optimization results and write a summary file named opt_results_3.txt. Briefly
review its contents.
5 Write down the cost of the optimized design and the angle of the hood.
$_______________, __________________
6 Were you able to save some cost by loosening the tolerance on the hood angle?
____ Yes____ No
7 Animate the optimized design with trace markers for:
PART_1.MARKER_front, PART_1.MARKER_rear
8 Export the optimized model in command file format as after_OPT2.cmd.
OptionuI tusks
1 Optimize the sla model from Workshop 4Parameterizing an Existing Model by
following the steps in Optional Task 3 on page 90.
2 Read the chapter, About Optimization in the guide, Refining Model Designs in ADAMS/
View to learn about other optimization settings. Try some and see how they work.
3 Use a customized menu button to evaluate design objectives and design constraints.
Import the file misc/eval_menu_buttons.cmd. From the Simulate menu, point to Design
Constraint, and then select Evaluate.
4 Repeat this workshop using a different starting point. Use the third design from
Workshop 5Parameterizing a New Model on page 95 by importing the file,
misc/wkshp_05_3rd_design_setpoint.cmd.
There is a known bug where lengthy user-written interpreted functions are not written out correctly
(CR24536). You will encounter errors if you try to read it back in. Workaround: replace function create
text with that from find_intersection.cmd.
Workshop -Optimizution,,,
167
9
COMMAMD LAM9UA9
Become familiar with the ADAMS/View command language while using a
model of a wing retraction mechanism.
Whut's in this moduIe:
s General Structure, 168
s Getting Familiar with Commands, 169
s Types of Commands, 173
s Workshop 9Understanding the Command
Language, 174
168 Command Language
9eneruI Structure
Syntu ruIes for communds-
s Comment lines are allowed by placing an exclamation point (!) as the first character
on the line.
s Continuation of a command is denoted by an ampersand (&) at the end of a line.
s Abbreviations are allowed, as long as they are unique.
s Examples:
x marker delete marker_name=.mod1.par4.mar27
x marker delete &
marker_name=.mod1.part4.mar27
x mar del mar=.mod1.par4.mar27
x mar del mar=mar27
Syntu ruIes for vuIues
The rules for entering values are:
s Values can contain letters, numbers, and underscore characters.
s They must begin with a letter or underscore character.
s Values can contain any characters that are enclosed by double quotation marks.
s They must have separators (blank space or tab) between keywords and parameters.
Placing separators between parameters and their values is optional.
s All parameter values of type string should be enclosed in double-quotes ().
s All parameter values of type object will accept the full database name or the relative
object name, provided it is unique in the database.
Main point: ADAMS/View is command driven.
May get questions on length of line. Explain that ADAMS/Solver has an 80-character limit, but ADAMS/
View commands do not.
Cover command abbreviation, and mention that a full command is preferred.
One gotcha when writing command files is that the last line might not get executed. Therefore, make it
a habit of making the last line a comment character (!).
Separator (blank or tab)
KEYWORD KEYWORD PARAMETER_NAME=VALUE PARAMETER_NAME = VALUE , VALUE
Parameter Parameter
Command Language 169
9etting FumiIiur with Communds
Commund Muvigutor
Commund Window
Log fiIe
170 Command Language
9etting FumiIiur with Communds,,,
Commund Muvigutor
Enables you to browse through the ADAMS/View command language and execute commands.
s The entire ADAMS/View command language is accessible through the Command
Navigator.
s Use the Command Navigator to navigate on keywords.
s Double-clicking the last keyword of a command displays a dialog box of parameter
names and parameter values.
s Example:
Commund Window
Log FiIe
Double-clicking here
opens...
Which executes the command:
xy_plots template delete title plot_name = .plot_1
Command Language 171
9etting FumiIiur with Communds,,,
Commund Muvigutor
Commund Window
Text-based way to enter commands. Assumes that you understand the ADAMS/View command
language.
Commund History
s Use the up and down arrows on your keyboard to scroll through previously executed
commands.
Commund punsion
s Use a question mark (?) or the Esc key for help with completing commands:
x Completes keywords or parameter names.
x Prompts for keywords or parameter names.
x Prompts for parameter values.
Log fiIe
Input
field
Command
information
area
172 Command Language
9etting FumiIiur with Communds,,,
Commund Muvigutor
Commund Window
Log fiIe
s A file named aview.log is saved during each ADAMS/View session. In the vertical
applications, it is called acar.log, aengine.log, and arail.log.
s Contains commands that you entered and messages you received.
s The previous sessions log file name is aview.log% on Unix and aview.loq on NT.
Command Language 173
Types of Communds
ADAMS/View commands can be categorized as follows:
ModeI-bused
umpIes:
marker create marker_name=mar1 location=2,0,0
marker modify marker=mar1 orientation=0d,90d,0d
Interfuce-bused {9UI}
umpIe:
interface dialog box display &
dialog_box_name = .gui.db_beam_size &
parameters=$f_beam_name
ConditionuI constructs
ADAMS/View command language contains commands for creating conditional constructs and
loops.
s BREAK
s CONTINUE
s IF/ELSE/ELSEIF/END
s FOR/END
s RETURN
s WHILE/END
fiIe tet write
This command writes information from ADAMS/View into a text file. You control the format
of the output and, using database access expressions, you can write any model or simulation data
from the ADAMS/View database.
Note: For additional information on the file text write command, refer to the Knowledge
Base Article 7017 available at: http://support.adams.com/kb/faq.asp?ID=7017.
174 Command Language
This workshop takes about one hour to complete.
ProbIem stutement
In this workshop you will become familiar with the ADAMS/View command language while
using a model of a wing retraction mechanism. You will learn how to write a command file, how
to use the command line for command input, where to go for syntax help, and more.
9etting sturted
To import the modeI:
1 Start ADAMS/View from the mod_09_cmd_lang directory.
2 Import the wing retraction model, wing_retractor_start.cmd.
XII I
II
III
IV
V VI VII
X
XI
VIII
IX
Workshop 9-Understunding the Commund Lunguuge
Command Language 175
ecuting u simpIe commund
In the ADAMS Basic Training class you learned how to use the graphical user interface (GUI)
to build your models. What you may not have realized at the time was that you could have built
them just the same by executing individual commands instead of using the interface. As you
heard in the last lecture, ADAMS/View has a command language. Learning more about this
language will make you a better ADAMS/View user.
Verifying u modeI
Many actions performed with the interface have equivalents in ADAMS/View command
language. You may have seen these commands scroll by in the Command Window or noticed
them in your aview.log file. To begin getting comfortable with the language, you will learn the
command that verifies a model.
To verify the modeI:
1 Display the Command Window so that you can see commands echoed to the screen.
s From the View menu, select Command Window (or you can use the F3 shortcut key).
2 Verify the model by right-clicking the I icon in the Status Bar and selecting the checkmark
icon.
3 From the Tools menu, select Model Verify.
This also verifies the model.
4 Look in the Command Window. What is the command for verifying a model?
______________________________________________________________________
5 In the text box at the bottom of the Command Window, type the command for verifying a
model, and then select Enter.
6 Did it verify the model the same as it did using the interface? _____ Yes _____ No
Input field
Workshop 9-Understunding the Commund Lunguuge,,,
176 Command Language
Commund history eumpIe
The command line input field has helpful features, such as command completion and command
history. Lets use some of them.
To use the commund Iine with history:
1 Place your cursor in the Command Window and click in the input field to activate the
window.
2 Click the Up arrow on your keyboard to see the last command entered, it should be model
verify.
3 Press Enter.
ADAMS/View executes the command.
Notice that the Information window has become cluttered with multiple verify operations.
4 Clear the contents by selecting Clear in the Information window.
5 What was the command that cleared the window?________________________________
Workshop 9-Understunding the Commund Lunguuge,,,
Command Language 177
Commund compIetion eumpIe
At times when you do not remember the full name of a command or its parameter list, you can
use command completion.
In the previous section, you cleared the Information window using an abbreviated command
(info empty). You can learn the full syntax by using command completion.
To use the commund compIetion to cIose the informution window:
1 Enter the following two characters into the Command Window: in
2 Type a question mark (?).
Notice that the Command Window shows that there are two commands that start with the
characters in: interface and info_window.
3 Type the third letter, f, and then enter a question mark.
Notice how ADAMS/View automatically completes the command (with info_window)
when it has enough information to see that it is unique.
4 Enter another question mark, or the Esc key.
The Command Window shows the parameters that are now available. They are: close,
empty, up_page, down_page, read, and set.
Note: The set, up_page, and down_page parameters are obsolete. Occasionally you
may run across old commands in the interface that are no longer being used.
5 Complete the command that will close the information window.
You have just learned how to execute a command by using the command line input. But, what
if you don't even know the first character of a command?
6 Clear the contents of the command line.
7 Type a question mark.
The Command Navigator opens. It displays many of the commands you can use in
ADAMS/View. You can go here for help when you don't know the command syntax. You
will learn more about it later on.
info_window close
Workshop 9-Understunding the Commund Lunguuge,,,
178 Command Language
8 Close the navigator.
Look in the Command Window. Can you see any commands issued to the Command
Window that are equivalent to the closing of the Command Navigator? You probably have
noticed there werent any equivalent commands. There are some GUI operations that are
done in code that are neither shown to you nor echoed to the Command Window.
Using the Commund Muvigutor
Quite often you will see that there are multiple paths to the same command. Earlier you saw that
the GUI has more than one way for you to verify a model, but each use the same underlying
command.
You can see all of these underlying commands arranged in a hierarchical fashion in the
Command Navigator.
To use the Commund Muvigutor to turn off the uppeurunce of u murker
icon:
1 If the model icons are not already visible, turn them on by selecting Icons in the Main
Toolbox.
2 From the Edit menu, select Appearance.
3 In the Database Navigator, browse to and select PART_12.cm.
4 In the dialog box that opens, set Visibility to Off, and select Apply.
5 Look at the command that was issued in the Command Window:
This is the command you want to issue by using the Command Navigator.
Workshop 9-Understunding the Commund Lunguuge,,,
Command Language 179
6 Undo the command so the marker is visible again. (Select Undo from the Main
Toolbox.)
7 Display the Command Navigator by selecting Command Navigator from the Tools menu.
8 Select entity, and then attributes.
The Entity Attributes dialog box opens.
9 Compare this Entity Attributes dialog box to the Edit Appearance dialog box.
Notice that there are some differences in what and how the information is presented.
Usually you will find the dialog boxes from the Command Navigator to be more generic,
whereas dialog boxes from other parts of the interface are specialized for certain tasks or
tailored to look a special way. All the dialog boxes from the Command Navigator are auto
generated. This is a nice feature that you can use when you need a basic dialog box for a
macro you may have written. More information on dialog boxes will come in Workshop
9Understanding the Command Language on page 174.
Tip: Auto-generated dialog boxes may not always display the correct options and text
box values. If you place your cursor in the Name text box and press Enter, the
information will update with the correct information.
10 Complete the Entity Attributes dialog box (shown above on the left) the best you can and
see if you can turn off the visibility of the marker, PART_12.cm.
Hint: Use Visibility instead of Expr Visibility.
Workshop 9-Understunding the Commund Lunguuge,,,
180 Command Language
You saw how to use the Command Navigator to turn off the appearance of a single marker.
What if you wanted to turn off more than one marker? You can use wildcards, such as the
asterisk (*).
11 Turn off all markers using a wildcard:
s Entity Name: .model_1.*
s Type Filter: marker
s Visibility: off
s Name Visibility: off
12 Select Apply.
Notice all the markers have turned off.
If you want to learn about other wildcards, see Using Wildcards in the guide, Learning
ADAMS/View Basics.
Workshop 9-Understunding the Commund Lunguuge,,,
Command Language 181
ecuting communds in u fiIe
The commands that you issue can be stored in a file and imported as needed. For example, say
you want to turn the visibility of all the markers back on by importing a file.
To eecute communds in u fiIe:
1 Look in the Command Window until you find the commands that just turned off the
marker visibility with the wildcard.
2 Highlight the commands, right-click, and then select Copy.
Selecting Copy places them on the clipboard.
3 Open a text editor and paste in the commands.
Look closely at the commands and compare them to the dialog box. You will see that there
is a strong similarity (nearly identical) between the command language syntax and the field
names in the dialog box. Observing and studying this information is another way to learn
the command language which helps you to write and understand command files.
4 Edit the text, changing the visibility parameter to on, instead of off.
5 Save the file as all_markers_on.cmd.
6 Import the file to execute the commands.
The markers turn on.
7 Modify the file, changing the visibility to off.
8 Save the file as all_markers_off.cmd.
9 Import the file to turn off the marker visibility using the F2 keyboard shortcut.
The markers turn off again.
10 Looking at the command files youve written, will they work as is, on a model that is
named .model_2? _____ Yes _____ No
11 This name-specific dependency is quite common. Which of the following seems like the
best solution to this sort of problem (check one):
____ Hand-edit the file every time you want to use it on a different model.
____ Always name all of your models .model_1
____ Write the command file more generically so that it's not model-name dependent.
____ Just use the interface and don't write your own command files.

Workshop 9-Understunding the Commund Lunguuge,,,


182 Command Language
Using epressions to muke communds more generic
In Workshop 4Parameterizing an Existing Model, you turned the visibility of cylinder
center_markers on and off by importing a command file. That file was written generically so
that it could be used on any model, whether its named .model_1, .sla, or something else. Let's
briefly look at the command language and expression syntax that was used.
To Iook ut the commund Iunguuge:
1 Open the file utils/ctr_mar_on.cmd.
This file uses a for-loop construct. You will learn more about that later in Workshop 10
Conditional Constructs and Loops on page 194. For now, we will concentrate on the
expression.
2 Look at the expression:
(eval(DB_CHILDREN(DB_DEFAULT(.system_defaults,"MODEL"),"cylinder")))
This is a nested expression, so it is helpful to consider it in pieces:
When you combine or nest these expressions, it will give you all the cylinders in the default
model. Once the cylinders were obtained, their center_markers were turned off.
(eval(DB_CHILDREN(DB_DEFAULT(.system_defaults,"MODEL"),"cylinder")))
This piece will evaluate the expression, leaving
you with the list of objects you asked for.
This piece will return all the cylinders that are children
of a given entity, for example, all the cylinders in .sla.
This piece will return the default
model, for example, .sla.
Workshop 9-Understunding the Commund Lunguuge,,,
Command Language 183
Turning off the visibiIity of geometry using u commund fiIe
Here, you will turn off the appearance of all the links, cylinders, extrusions, and ellipsoids for a
given model in a generic way like youve just seen with the nested expression. An example of
this is provided in your mod_09_cmd_lang directory.
To turn off the visibiIity of geometry:
1 Using a text editor, open the file, rigid_geom_off.cmd.
2 Review the commands and see if they make sense to you.
Each piece of geometry is handled with its own command.
3 Based on these commands, which of the following geometry types will be turned off?
____ Link ____ Extrusion ____ CSG
____ Cylinder ____ Ellipsoid ____ Plate
4 Import the command file and watch how it turns off the geometry in the wing retraction
model.
The icons may be obscuring your view of the mechanism.
5 Turn off all icons with the v keyboard shortcut.
Notice that some of the geometry still remains, as shown below.
Workshop 9-Understunding the Commund Lunguuge,,,
184 Command Language
6 What kind of geometry is still displayed? Circle the best answer.
Link Extrusion CsgSolid Plate
Tip: Getting information on a piece of geometry will give you a clue.
Now you need to modify the command file so it will turn off the visibility of the CsgSolid
geometry.
To modify the commund fiIe:
1 Using a text editor with the rigid_geom_off.cmd file displayed, write the command language
needed to turn off the CsgSolid geometry.
The easiest way would be to copy one of the commands for the other geometry types and
modify it accordingly.
2 Save your changes.
3 Test the file by importing it.
4 Did the CsgSolid geometry visibility turn off? _____ Yes _____ No
5 Modify the file so that it will turn the geometry back on, and then save it as
rigid_geom_on.cmd.
6 Import the file rigid_geom_on.cmd.
Your CsgSolid geometry should be visible again.
Writing commund fiIes-
You have been assigned to a team. Work together with the members of your
team to complete this section.
By now you have become familiar with the basics of command language. See if you can do the
following tasks without having any detailed steps provided.
Instructor Note: Divide the class into teams, explaining that the next section is a team exercise. Emphasize
that they should work together to solve any problems they encounter. If the team is stuck, they can ask the
instructor for help.
Workshop 9-Understunding the Commund Lunguuge,,,
Command Language 185
Tusk 1
1 Write a command file named task_1.cmd that will create a marker called wing_tip on
PART_12 that can be used to trace the path of the wings tip during animation.
Do so by only reviewing the Command Navigator and dialog box for keywords and
parameters, not by executing the command (via the GUI, command line, etc.).
2 Import this command file.
3 Did it work as expected? _____ Yes _____ No
Tusk Z-
1 Write a command file named task_2.cmd that:
s Sets the execution display never update.
s Submits a transient simulation (2sec/100steps).
s Resets the simulation.
s Animates the front view for 5 cycles using a range of frames (1 through 51) and
wing_tip (from previous task) as the trace marker.
s Pauses. (Hint: Use the Pause command.)
s Numeric_results - list_info - all for the result_set_component JOINT_9.FX, and save as
joint_9_info.txt.
s Sets view window to model display.
s Sets execution display back to update at every output step.
2 After you've written the command file, modify it (as needed), save it as task_2_batch.cmd,
and run it in batch mode:
adams11 aview ru-s b task_2_batch.cmd exit
3 Review the aview.log file to confirm that there were not any errors in the batch file.
Proceed to the next page for the final team task.
The most common mistake is forgetting to include a file command read file=... command to import
the wing model first.
Workshop 9-Understunding the Commund Lunguuge,,,
186 Command Language
Tusk 3
The attached command file, dbox_visibility_start.cmd, makes a customized dialog box that
provides an easy way to control entity appearance and icon size (see the dialog box below).
Many of the buttons work; however, two of the buttons arent hooked up with the correct
commands and youll receive errors when you try to use them.
1 See if you can find the broken buttons and then fix them (by hand-editing the command
file) so that it works properly.
2 Save the repaired file as task_3_dbox_visibility.cmd.
3 Would this customized dialog box be useful in your everyday ADAMS work?
_____ Yes _____ No
ERROR: 'joint' is not a valid keyword.
solution: Joint visibility checkbox should use 'constraint' keyword, not 'joint'
ERROR: 'entity_names' is not a valid parameter.
solution: 110% button should be using 'entity_name' parameter, not entity_names
(i.e., there was an extra s that shouldve been removed)
Workshop 9-Understunding the Commund Lunguuge,,,
Command Language 187
OptionuI tusks
1 Modify rigid_geom_on.cmd and rigid_geom_off.cmd so that they also handle the plate
geometry type.
2 Search the knowledge base and find kb7954 which has a command file (kb7954.cmd)
that you can use to control the appearance and color of joint markers. Modify that
command file so that it also works on joints and joint primitives, and save the file as
constraints.cmd.
Hint: To see all the database types, you can use the procedure outlined in kb9027.
3 Write a command file results_image_batch.cmd that does the following (simple steps are
provided):
a Import parameterized model completed_mod_06.cmd.
x From the File menu, select Import.
b Render model smooth shaded.
x From the View menu, point to Render Mode, and then select Smooth Shaded.
c Set to front view.
x From the View menu, point to Preset, and then select Front.
d Change a design variable.
x From the Build menu, point to Design Variable, and then select Modify.
e Run a simulation.
x From the Simulate menu, select Scripted Controls.
f Animate with traces on.
x From the Review menu, select Animation Controls.
g Fit to view.
x From the View menu, point to Position/Orientation, and then select Fit.
h Zoom out two times.
x From the View menu, point to Position/Orientation, and then select Zoom Out.
i Create .jpg hardcopy of view window.
x From the Tools menu, point to Command Navigator, and then select hardcopy.
Step 2: If the Knowledge Base is inaccessible, see the directory, completed/optional/kb7954.
Workshop 9-Understunding the Commund Lunguuge,,,
188 Command Language
Workshop 9-Understunding the Commund Lunguuge,,,
189
J0
COMDITIOMAL COMSTRUCTS AMD LOOPS
Construct logic so that a group of commands are executed conditionally (that is,
only if certain criteria are met).
Whut's in this moduIe:
s FOR/END Loop (Numeric Iteration), 190
s FOR/END Loop (Object-Based), 191
s WHILE/END, 192
s If/Then/Else, 193
s Workshop 10Conditional Constructs and
Loops, 194
190 Conditional Constructs and Loops
FOR/MD Loop {Mumeric Iterution}-
Overview
The FOR and END commands allow you to execute a group of commands a fixed set of times.
This example performs numeric iteration. ADAMS/View executes the commands bracketed by
the FOR and END for each value of a variable in the specified range.
You can nest any combination of looping (FOR/END, WHILE/END) and conditional constructs
(IF/ELSEIF/ELSE/END).
Syntu
FOR VARIABLE_NAME=var START_VALUE=REAL &
INCREMENT_VALUE=REAL END_VALUE=REAL
...
END
ADAMS/View executes the commands between the FOR and END for each value of var, in the
range START_VALUE to END_VALUE. At the beginning of the FOR loop, ADAMS/View
creates an ADAMS/View variable of type REAL named var. ADAMS/View deletes the variable
when the loop terminates. If you use the loop variable in an expression that requires it to persist,
ADAMS/View issues a warning message and does not delete the variable at the termination of
the loop. If you do not want this to happen, you can use the EVAL function.
START_VALUE, INCREMENT_VALUE, and END_VALUE can be any valid real expression.
INCREMENT_VALUE can be either positive or negative, and defaults to 1.0 if not specified. If
INCREMENT_VALUE is positive, ADAMS/View increments the value of var by the increment
for each iteration and stops looping when the value of var is greater than END_VALUE. If
INCREMENT_VALUE is negative, ADAMS/View decrements var by the increment for each
iteration and continues looping until var is less than END_VALUE.
The commands inside the FOR/END loop can use var as they would any other ADAMS/View
variable of type REAL.
umpIe
In this example, ADAMS/View creates 10 markers, MAR1 through MAR10, on the default part,
and locates them one unit apart on the x-axis of the parts reference frame.
for variable_name=tempreal start_value=1 end_value=10
marker create marker_name=(eval("MAR" // RTOI(tempreal))) &
location=(eval(tempreal-1)), 0, 0
end
Direct them to the from_online_doc subdirectory for examples of each of these constructs. Also refer
them to kb9093.
Conditional Constructs and Loops 191
FOR/MD Loop {Obgect-used}
Overview
The FOR and END commands allow you to execute a group of commands a fixed set of times.
This example operates on a set of ADAMS/View objects, such as markers or parts.
ADAMS/View executes the commands bracketed by the FOR and END on the specified set of
objects.
You can nest any combination of looping (FOR/END, WHILE/END) and conditional constructs
(IF/ELSEIF/ELSE/END).
Syntu
FOR VARIABLE_NAME=var OBJECT_NAMES=objects &
TYPE=database_object_type
...
END
For this type of FOR loop, ADAMS/View creates an ADAMS/View variable of type OBJECT
and successively assigns the value of the each object in the set to the variable. The commands
inside the FOR/END pair can use var as they would any other ADAMS/View variable of type
OBJECT.
umpIe
In this example, ADAMS/View renumbers the ADAMS IDs of markers belonging to the part
follower, starting at 5000, and incrementing by one for each marker in the set.
variable create variable_name=ip integer_value=5000
for variable_name=the_marker object_names=.fourbar.follower.* type=marker
marker modify marker_name=(eval(the_marker)) adams_id=(eval(ip))
variable modify variable_name=ip integer_value=(eval(ip+1))
end
variable delete variable_name=ip
192 Conditional Constructs and Loops
WHIL/MD
Overview
Use the WHILE and END commands to execute a group of commands zero or more times.
ADAMS/View executes the commands that WHILE and END bracket repeatedly until the
condition associated with the WHILE command is FALSE (zero).
You can nest any combination of looping (FOR/END, WHILE/END) and conditional constructs
(IF/ELSEIF/ELSE/END).
Syntu
WHILE CONDITION=(expression)
...
END
umpIe
In this example, ADAMS/View creates 10 markers, MAR1 through MAR10, on the default part,
and locates them one unit apart on the x-axis of the parts local part reference frame (LPRF).
variable create variable_name=ip integer_value=0
while condition=(ip < 10)
marker create marker_name=(eval("MAR"//ip+1)) &
location=(eval(ip)),0,0
variable modify variable_name=ip integer_value=(eval(ip+1))
end
variable delete variable_name=ip
Conditional Constructs and Loops 193
If/Then/Ise
Overview
Use IF/ELSE to execute a group of commands conditionally. The execution of commands
bracketed by IF and END depends on the value of an expression.
Syntu
umpIe
In the following example, if the marker MAR1 exists, ADAMS/View modifies its location. If the
marker does not exist, ADAMS/View creates it and sets its location.
if condition=(DB_EXISTS ("MAR1"))
marker modify marker=mar1 location=2,0,0
else
marker create marker=mar1 location=2,0,0
end
IF CONDITION=(expression)
...
END
IF CONDITION=(expression)
...
ELSE
...
END
IF CONDITION=(expression)
...
ELSEIF
...
ELSE
...
END
Helpful operators:
!= not equal to
&& logical AND
|| logical OR
== equal to
< less than
For information on these
and other operators, refer
to the Expression
Language Reference
chapter in the guide,
Using the ADAMS/View
Function Builder.
194 Conditional Constructs and Loops
This workshop takes about one hour to complete.
ProbIem stutement
In this workshop you will become familiar with the features of ADAMS/View command
language that allow you to execute a group of commands repeatedly, or build a series of similar
objects. You will also learn how to construct logic so that a group of commands is executed
conditionally, that is only if certain criteria are met. To practice using these features you will
use models from previous workshops (parameterized hood mechanism and wing retraction
mechanism) and a new model (simple diskette).
efore you sturt
The from_online_doc subdirectory contains examples of conditional constructs that are in the
ADAMS online guides. You may want to review them if you are curious about whats available
or want to see a simple example.
XII I
II
III
IV
V VI VII
X
XI
VIII
IX
Workshop 10-ConditionuI Constructs und Loops
Conditional Constructs and Loops 195
9etting sturted
To import the modeI:
1 Start ADAMS/View from the mod_10_conditionals_loops directory.
2 Import the hood mechanism model, hood_4_start.cmd.
About eecuting communds repeutedIy
Recall that in Workshop 6Performing a Design Study on page 121, you swept the values of
the design variables using a Sweep Variable customized feature. Behind the scenes, Sweep
Variable was executing commands repeatedly; nothing more than just modifying a design
variable again and again. It worked by taking the variables lower range value and increasing it
repeatedly until it reached the upper limit of the range. To achieve this repetitive task, a FOR
loop construct was used. Here you will use a FOR loop to mimic the sweep variable operation.
Following is a simple example of a FOR/END loop in ADAMS/View language:
for var=h start=1 end=5 inc=1
command_to_execute(h)
end !for
This construct will execute a command five times. When you issue a FOR loop like this,
ADAMS/View knows to go ahead and create the h variable. Its a temporary variable, and it
exists until the FOR loop has finished, at which time it is automatically deleted.
Note: Here, h was chosen for example purposes, but in practice you can use any variable
name that you want, i, k, my_counter, or something else.
As shown above, the commands you want to execute can and may be a function of h, but you
should not make them parametrically dependent on h. If you did make them dependent,
ADAMS/View wouldnt be able to delete h when the loop had finished and you would
encounter an error. To avoid this problem, you will want to use the EVAL function so that
dependency on h is not established.
In the simple example, the h variable starts out with a value of 1, each pass through the loop, h
is incremented by 1 until it reaches the end value of 5, at which time the FOR loop is ended. The
net result is that the command_to_execute is executed five times.
Workshop 10-ConditionuI Constructs und Loops,,,
196 Conditional Constructs and Loops
Writing u FOR Ioop to sweep u vuriubIe
In this exercise, you will sweep the value of design variable D1 in the hood model so you see
five frames evenly-spaced within its absolute range.
The FOR loop language syntax supports reals as well as integers. That makes this task simpler
because the values of D1 are not integers.
As you can see from the above figure the start, end, and inc values are 0.15, 0.85, and 0.175
respectively.
To write u FOR Ioop:
1 Set to Front View so you can see the effect of D1 as its being swept.
2 Sweep the value of D1 by issuing the following commands:
Do this by entering the commands through the Command line.
3 Now, to sweep D1 backwards from where it finished, you can use another FOR loop, this
time negating the increment and swapping the start and end values:
for var=h start=0.85 end=0.15 inc= -0.175
var set var=d1 real=(eval(h))
end
Enter the above commands at the Command line so the value of D1 sweeps backward.
for var=h start=0.15 end=0.85 inc=0.175
var set var=d1 real=(eval(h))
end
NOTE: Nothing will happen until
you enter the end command.
Frame
1 2
D1
0.15 0.325 0.5 0.675 0.85
Start
inc
End
Workshop 10-ConditionuI Constructs und Loops,,,
Conditional Constructs and Loops 197
4 Using a text editor, write a command file swing_sweep_D1.cmd that uses FOR/END
constructs to sweep the value of D1 forward and backward as follows:
s from 0.50 to 0.85 using 3 frames
s from 0.85 to 0.15 using 5 frames
s from 0.15 to 0.50 using 3 frames
Run the file from the Command line.
Hint: Here is the abbreviated command:
fi com re fi=swing_sweep_D1
5 Did the command file work properly? ____Yes ____No
Tip: In order to see the View window, you may need to move the Import dialog box
aside before you select OK.
6 Now try executing the commands again, this time by importing the command file using
the File menu and selecting Import, or by using the F2 key.
7 Did the command file work as expected this time? _____Yes ____No
8 What do you think the problem is? Check one.
_____ FOR/END loops only work from the Command line.
_____ The commands get executed so fast in a FOR/END loop that Im unable to see them.
_____ I must have imported the file incorrectly.
_____ The commands are being executed properly, but the screen isnt being updated.
9 Add the following command to the top of your swing_sweep_D1.cmd file and then save it:
defaults command_file update_screen=on
10 Import the command file again. You will see that this time it updates the screen as D1 is
being swept.
You have learned the usefulness of the FOR/END construct in a simple application. It is even
more powerful when you apply it to model building.
Workshop 10-ConditionuI Constructs und Loops,,,
198 Conditional Constructs and Loops
uiIding modeI entities using FOR/MD Ioops
Sometimes you need to create several entities that are similar, such as several links in a chain
or several parts that make up a discretized beam. Instead of manually building these parts
individually, you can create them using a FOR/END construct.
For example, you have a part in your model that you would like several copies of, and you want
the location of each copy to be offset a given distance, d, as depicted below:
There are several ways you can do this. You could write FOR/END loops that use numeric
iteration, which could perform the copy and move operations. But here, youll use a different
approach. You will write a FOR/END loop that operates on a set of objects and use that with a
WHILE/END loop.
To write u FOR Ioop to copy u purt und move it:
1 Start a new database and import the model named diskette_0_start.cmd.
2 Shade the model using the Render button. Set the view to Isometric and Fit to View.
Original Copy 1
Copy 2
. . .
d
d
Workshop 10-ConditionuI Constructs und Loops,,,
Conditional Constructs and Loops 199
3 Copy the DISK_0 part by entering the following command at the Command line:
part copy part=DISK_0 new_part=DISK_1
You should now have a copy named DISK_1 superimposed upon DISK. You can right-click
the object to see the part names.
There are several commands available to move parts. You will use the move object
command to move DISK_1 in the z-direction of the local part reference frame (LPRF).
4 Using the Command line input field, enter this command:
move object part=DISK_1 c1=0 c2=0 c3=5.0 cspart=DISK_0
You should now have two diskettes in the model as shown below.
Workshop 10-ConditionuI Constructs und Loops,,,
200 Conditional Constructs and Loops
Copying und moving the purts
In this exercise we will perform the copy and move operations in two separate stages:
s Stage 1: Copy DISK_0 several times with a WHILE/END loop.
s Stage 2: Take the copies and move them relative to each other with a FOR/END loop.
Stuge 1 - Copying DISK_0 using WHIL/MD Ioop
To copy DISK_0:
1 Using a text editor, create a file named copy_via_while_end.cmd that contains these
commands:
defaults model model_name = .model_1
variable create variable_name=ip integer_value=0
while condition=(ip < 5)
part copy part=.model_1.DISK_0 new_part=(UNIQUE_NAME("DISK"))
variable modify variable_name=ip integer_value=(eval(ip+1))
end !while
variable delete variable_name=ip
2 Import the command file you just created.
3 Did it make several copies of DISK_0? ___Yes ___No
Tip: Look in the Table Editor and filter on Parts.
If not, see if you can determine what the problem is. Refer to
from_online_doc/ex6_while_end.cmd if you have questions, or to see another
WHILE/END example.
Workshop 10-ConditionuI Constructs und Loops,,,
Conditional Constructs and Loops 201
Stuge Z - Moving the copies
To move the copies:
1 Again use a text editor and create a file named move_via_for_end.cmd that contains these
commands:
defaults model part_name = .model_1.DISK_0
for var=the_part obj=.model_1."DISK_[^0]*" type=PART
move object part_name = (the_part) &
c1=0 c2=0 c3=+5.0 &
cspart_name = (eval(DB_DEFAULT(.SYSTEM_DEFAULTS, "part")))
defaults model part_name = (eval(the_part))
end !for
Notice that wildcards are used so that DISK_0 is not included in the list of objects to be
moved.
2 Import the command file move_via_for_end.cmd.
3 Did it move all of the copies of DISK_0? ___Yes ___No
If not, see if you can determine what the problem is. Look in the Table Editor to view the
part locations.
Now you have learned how to use a WHILE/END construct and the object form of a FOR/
END construct.
4 Exit ADAMS/View.
Workshop 10-ConditionuI Constructs und Loops,,,
202 Conditional Constructs and Loops
Using conditionuI Iogic
Recall that in Workshop 9Understanding the Command Language on page 174 you wrote a
command file that created a marker called wing_tip. You saw that it could only be read in once
because importing it a second time generated the error: The Marker 'wing_tip' already exists.
You can prevent problems like this by using conditional logic. You can have ADAMS/View
check if a marker already exists, and if it doesnt, it will create it. Otherwise, it won't.
To use conditionuI Iogic:
1 Start ADAMS/View again in the mod_10_conditionals_loops directory.
2 Import the wing retraction model in wing_retractor_2_start.cmd.
Next, you will use IF logic to decide whether or not to create a marker.
Here is a simple example of using IF/ELSE/END logic from the online guide, Customizing
ADAMS/View (Appendix A, Conditional Constructs and Loops):
if condition=(DB_EXISTS ("MAR1"))
marker modify marker=mar1 location=2,0,0
else
marker create marker=mar1 location=2,0,0
end
This conditional construct is self-explanatory. If a marker named MAR1 is in the
ADAMS/View database, its location will be modified; if it's not in the database, it will be
created with the specified location.
Tip: If you'd like to try the above example, you can find it in
from_online_doc/ex3_if_else.cmd. Import it more than once so you test both halves
of the logic.
3 Using this example as a guide, modify the task_1.cmd command file you wrote earlier in
Workshop 9Understanding the Command Language so that it only creates the wing_tip
marker if it doesnt already exist in the ADAMS/View database. Otherwise, it does
nothing.
4 Save the file as task_1_with_IF.cmd.
Workshop 10-ConditionuI Constructs und Loops,,,
Conditional Constructs and Loops 203
5 Test the conditional logic by importing the file task_1_with_IF.cmd more than once.
Did it work? ____ Yes ____No
6 Did you use the else command in your logic, like this? ____Yes ____No
if condition=(DB_EXISTS("wing_tip"))
!do nothing
else
marker create &
marker_name = .model_1.PART_12.wing_tip &
location = 366.5429353715, -233.5860133171, 0.0 &
relative_to = .model_1.ground
end
7 The conditional check for existence of wing_tip can be performed with either of the
following, without using else:
s if condition=(DB_EXISTS("wing_tip")==0)
marker create...
end
s if condition=(!DB_EXISTS("wing_tip"))
marker create...
end
8 Delete wing_tip from the model and try the above examples.
DispIuying un uIert bo
You may want to display an alert message if a condition is not met. Here you will modify the
command file so it display an alert if the wing_tip marker is already there (instead of doing
nothing at all).
To dispIuy un uIert bo:
1 Open the online documentation, go to the guide, Using the ADAMS/View Function
Builder. Use the Search tool and find the full description of the ALERT design-time
function.
2 Review the Definition, Format, Arguments and Example.
3 Highlight the text of the example function and select Copy.
4 From the Tools menu, select Function Builder. Paste in the text you copied from the
documentation.
Workshop 10-ConditionuI Constructs und Loops,,,
204 Conditional Constructs and Loops
5 Edit the text to make it a single line, and then select evaluate. An alert box will appear as
shown.
6 Select No in the Alert dialog box to dismiss it.
7 In the Function Builder, modify the ALERT function so it says Marker wing_tip already
exists., and only has a Close button.
ALERT("Information", "Marker wing_tip already exists.", "", "", "Close", 3)
Workshop 10-ConditionuI Constructs und Loops,,,
Conditional Constructs and Loops 205
8 Evaluate the function.
It should display an alert box like this:
9 Highlight the function and select Copy.
10 Open your task_1_with_IF.cmd file, and paste the Alert function in the desired location and
add the additional variable set command as shown:
if condition=(DB_EXISTS("wing_tip"))
var set var=tmp_int &
integer=(ALERT("Information", "Marker wing_tip already exists.", "", "", "Close", 3))
else
marker create &
marker_name = .model_1.PART_12.wing_tip &
location = 366.5429353715, -233.5860133171, 0.0 &
relative_to = .model_1.ground
end
11 Save the file as task_1_with_ALERT.cmd.
12 Import the file you just saved and test it out.
Workshop 10-ConditionuI Constructs und Loops,,,
206 Conditional Constructs and Loops
Using the ALRT function for decisions
To use the ALRT function for decisions:
1 Run the file task_1_decision.cmd to see how an alert box can be used to obtain a decision
from a user.
2 Review the logic in the command file and see if it makes sense to you.
Look for these items that you might find useful when writing your own alerts, conditional
constructs, and customizations:
s Nested IFs and use of ELSEIF
s Use of temporary variables (tmp_int, tmp_str)
s Concatenation via "//"
s Self-referencing of a string variable (tmp_str)
s Use of STR_CHR function to cause a line feed in a message
s Use of the integer value returned by an ALERT function for decision making
s Use of SELECT_LIST and mdi modify_macro
s Deletion of temporary variables
3 What value does tmp_int become if the user just closes the Alert box without choosing one
of the buttons? _________________________
Workshop 10-ConditionuI Constructs und Loops,,,
Conditional Constructs and Loops 207
OptionuI tusks
1 Nest loop constructs.
s Create a command file, nested_swing_sweep_D1.cmd, that will execute the swing_sweep
operation three times for the hood model.
Tip: You cannot use the variable h for both the inner and outer loops.
2 Use a WHILE/END construct instead of a FOR loop.
s See if you can write a WHILE/END loop that sweeps the D1 variable of the hood
model from 0.15 to 0.85 in 10 frames.
s Save it as while_end_D1.cmd.
Tip: See the ex6_while_end.cmd example in the from_online_doc subdirectory.
3 Combine loops together.
s Combine the loops from copy_via_while_end.cmd and move_via_for_end.cmd into a single
command file named build_combined.cmd.
s Make the necessary modifications to the file so that it will create a model named
.model_2, that has a part named CUBE_0 (block geometry) and 10 copies offset by 500
length units in both the x and y global directions.
4 Use loops to create markers.
s Use FOR loops and expressions to create markers (pvMAR_*) that are parameterized to
the vertices of a polyline.
s Use the SELECT_OBJECT expression to allow the user to choose the polyline through
the Database Navigator.
s Save the file as markers_at_vertices.cmd.
Workshop 10-ConditionuI Constructs und Loops,,,
208 Conditional Constructs and Loops
Workshop 10-ConditionuI Constructs und Loops,,,
209
JJ
MACROS: OVRVIW
Learn the differences between macros and command files, how to use the macro
editor, and how to write some parameterless macros.
Whut's in this moduIe:
s Macro Overview, 210
s Creating Macros, 214
s Executing Macros, 218
s Debugging, 219
s Workshop 11Macros: Overview, 223
210 Macros: Overview
Mucro Overview
Definition
Purpose
Types
Macros: Overview 211
Mucro Overview,,,
Definition
A macro is an object that adds a command to the ADAMS/View language to execute a series of
ADAMS/View commands. ADAMS/View treats a macro as it does all other ADAMS/View
commands.
Purpose
Types
212 Macros: Overview
Mucro Overview,,,
Definition
Purpose
Automute modeI buiIding simuIuting und reviewing
s Examples:
x Generate a series of objects
x Generate a series of plots for a simulation
x Build an entire model (one for parts, one for joints, one for forces, and so on).
Automute user preferences
You can also write macros to automate how you work in ADAMS/View. For example, you can:
s Automatically turn icons on or off
s Specify a certain grid size
s Set whether or not to use the external ADAMS/Solver library, and so on.
s Examples:
x Icon settings (visibility, size, color)
x Grid settings (on/off, size, and so on)
x Solver preferences (use external/internal, save files, and so on)
Types
Macros: Overview 213
Mucro Overview,,,
Definition
Purpose
Types
PurumeterIess
s Executes the ADAMS/View commands stored in the macro.
With purumeters
s You can add parameters to a macro that will be evaluated when the macro is
executed.
s This makes the macro more generic.
214 Macros: Overview
Creuting Mucros
Mucro obgect purumeters
Wuys to creute mucros
Macros: Overview 215
Creuting Mucros
Mucro obgect purumeters
To create a macro, you must specify:
s Name (for database storage and reference).
x It is recommended that you save your macros in a user-created library. If you
save them in the .gui library, they will not be upward compatible.
s A command that will run the macro.
x The default is the macro name.
s The commands the macro will execute.
s What to do in case of a subsequent Undo.
Wuys to creute mucros
216 Macros: Overview
Creuting Mucros,,,
Mucro obgect purumeters
Wuys to creute mucros
Mucro editor
Record/RepIuy
Reuding from tet fiIe
Macros: Overview 217
Creuting Mucros,,,
Mucro editor
Here, you enter the name of the macro and a unique command string that executes the macro.
Record/RepIuy
You can create a macro by recording a sequence of steps. Once you start the recording process,
you perform the operations that you want to be included in the macro. Then, you stop the
recording process and play it back. You can also save the macro you just recorded.
Reuding from tet fiIe
s You can create a macro by using the Read command to read in an existing command
file containing the commands to be executed. You can also assign a help file or text
string to the macro that explains the macros use.
s The file you supply that contains the macro definition is a standard command file but
it can also contain parameters embedded in the commands and can have special
comments at the top.
Commands
text area
Example:
macro read &
file_name = "part_replicate_single_mac.cmd" &
macro_name = .par_rep_single
218 Macros: Overview
ecuting Mucros
When you create a macro, the command is added to ADAMS/View language.
Commund Iine
Enter the command (with any applicable parameters) in the command line of the Command
Window.
Commund Muvigutor
The Command Navigator displays a list of all ADAMS/View command keywords. When you
select an object, a dialog box appears in which you enter parameters for executing the command.
Custom diuIog boes
You can create a custom dialog box that, upon execution, executes a macro.
Other mucros
If needed, a command within a macro can execute another macro.
Command
line
Selecting this command...
opens this dialog box
Macros: Overview 219
Debugging
Using Iist informution und temporury vuriubIes
Using the Mucro Debugger
CruwI-wuIk-run upprouch
220 Macros: Overview
Debugging,,,
Using Iist informution und temporury vuriubIes
You can debug a macro if you:
s Create it in pieces.
s Store the pieces in variables.
s Get list information on variables.
For more information on building function expression strings in a macro, refer to the
Knowledge Base Article 7477, available at: http://support.adams.com/kb/faq.asp?ID=7477.
Using the Mucro Debugger
CruwI-wuIk-run upprouch
Macros: Overview 221
Debugging,,,
Using Iist informution und temporury vuriubIes
Using the Mucro Debugger
s Used for heavy development
s Unsupported and details undocumented
CruwI-wuIk-run upprouch
222 Macros: Overview
Debugging,,,
Using Iist informution und temporury vuriubIes
Using the Mucro Debugger
CruwI-wuIk-run upprouch
CruwI - Leurn the communds
s Use interface to facilitate.
s Execute by interface (GUI), Command Navigator, and so on.
s Review commands and parameters (log file and Command Window).
s Add to macro editor and test.
WuIk - Add purumeters und quuIifiers
s Declare parameters and simple qualifiers.
s Substitute parameters into commands.
s Test.
s Add looping constructs, if necessary.
s Use temporary variables.
Run - Fine tune
s Add comment lines
s Remove dependencies (model object names, environment, and so on).
s Add error trapping (using IF condition).
s Add detailed qualifier, as needed.
Macros: Overview 223
This workshop takes about one hour to complete.
ProbIem stutement
In this workshop you will become familiar with writing parameterless macros, while using the
wing retraction model used previously in Workshop 9Understanding the Command
Language on page 174 and Workshop 10Conditional Constructs and Loops on page 194.
You will be introduced to the differences between macros and command files, you will learn
how to use the macro editor, and will write some parameterless macros.
9etting sturted
To import the modeI:
1 Start ADAMS/View from the mod_11_parameterless_macros directory.
2 Import the wing retraction model, wing_retractor_start.cmd.
XII I
II
III
IV
V VI VII
X
XI
VIII
IX
Workshop 11-Mucros: Overview
224 Macros: Overview
Using Mucro Record und Mucro RepIuy
One of the simplest ways to create a macro is to record one as you perform operations in
ADAMS/View. This recorded macro can then be played back later and the exact same
operations will be executed again.
To record u series of operutions:
Use the macro record feature to save a favorite view and model configuration.
1 Turn on Render view.
2 Turn on the visibility of icons (if theyre not on already).
3 Initiate the macro recording operation:
s From the Tools menu, point to Macro, point to Record/Replay, and then select Record
Start.
4 Select an Isometric view.
Your model should look similar to the following:
JOINT_15
Workshop 11-Mucros: Overview,,,
Macros: Overview 225
5 Choose the center of the view to be near JOINT_15:
s From the View menu, point to Position/Orientation, select Center, and then pick roughly
at the location of JOINT_15 shown above.
Tip: The equivalent keyboard shortcut is c.
6 Zoom in dynamically using the z shortcut, until your view looks similar to the following:
7 Stop the macro recording operation:
s From the Tools menu, point to Macro, point to Record/Replay, and then select Record
End.
8 Reset your view to a front view and fit view.
9 Playback the macro you recorded:
s From the Macro menu, point to Record/Replay, and then select Execute Recorded Macro.
It should have returned your view to the zoomed in Iso view.
You may have noticed that the cursor appears to be active, highlighting objects as you
move the mouse around. Almost as if its in Pick mode, ready for you to pick something
off the screen. Lets investigate why.
JOINT_15
Workshop 11-Mucros: Overview,,,
226 Macros: Overview
10 Stop the highlighting mode by clicking the Select tool in the Main Toolbox.
Reviewing the communds in u recorded mucro
To review the communds:
1 Use the macro editor to see what commands were recorded:
s From the Tools menu, point to Macro, point to Edit, and then select Modify.
s In the Database Navigator, select record_macro.
You should see commands in the editor that resemble the following:
Note: The text shown in the dialog box above may differ slightly from what you see.
Every operation you performed has been recorded.
The second line shows an interface command being used. This was the one that put it in
Pick mode, and can be removed because you wont be prompted for the center (it was
hardcoded with command C).
A
B
C
D
E
A-Set the Iso view
B-Prompt user for
center of screen
C-Set the center view
with hardcoded
location values
D-Zoom out
E-End the recording
Workshop 11-Mucros: Overview,,,
Macros: Overview 227
2 Delete the commands B and E from the macro and select OK.
3 Reset the view to some other perspective of the model so you can test the macro.
4 Run the macro again.
The view returns to the zoomed view.
5 Run the macro again.
Notice that ADAMS/View zooms in more. Thats because commands instruct ADAMS/
View to increase the zoom, rather than set it to an exact value. If you don't want that effect,
you have to change the commands. For example, you could insert commands for a Fit to
View after the Iso.
6 Modify the recorded macro and insert the following command in the proper location: view
zoom auto=on.
7 Run the macro a couple of times. It should no longer be zooming more and more.
Suving u recorded mucro
There can only be one macro named record_macro in the database. If you were to start
recording again, ADAMS/View would overwrite the one you just created. Rename the macro
to save it in the database so it is not overwritten.
To suve u recorded mucro:
1 Clear the select list by clicking the Select tool on the Main Toolbox.
2 From the Edit menu, select Rename.
3 In the Database Navigator, perform the following:
s At the bottom to the right of the Filter box, choose All from the drop-down list. This
will allow the macro to be displayed above, as the Database Navigator normally
filters them out.
s Select record_macro.
s Select OK.
s In the Rename Object dialog box that appears, in the New Macro name text box, enter
.my_zoomed_view.
s Select OK.
Workshop 11-Mucros: Overview,,,
228 Macros: Overview
4 How do you think you can run the macro that you just saved?
_____ Type my_zoomed_view at the command line.
_____ Use the Command Navigator
_____ All of the above.
_____ None of the above.
5 Export the macro to a file:
s From the Tools menu, point to Macro, and then select Write.
s In the Macro_Name text box, enter .my_zoomed_view.
s Leave the File Name text box blank.
s Select OK.
6 Open the file with a text editor, and look at the command file that was written.
It shares more than just a strong resemblance to a command file because it is a command
file. The reason it doesn't look special is because it's a parameterless macro. If the macro
had parameters, it would look quite different. You'll learn more about these differences in
the next workshop (Macros: Syntax and Parameters on page 233). But for now you will
practice recording another macro and then progress to writing a parameterless macro by
hand.
To record unother mucro:
1 Now record another macro, whatever you'd like to try. Just make sure you perform a
variety of operations, at least five or six things.
2 Playback your newly recorded macro.
3 Did it work as expected? _____ Yes _____ No
You probably saw that it did more than you expected, or had problems because it couldn't
do certain things twice. In general, the macro record operation is good for short tasks or a
minimal set of operations.
4 Look at the recorded macro in the macro editor.
5 Are the commands fairly verbose and perhaps confusing to you?
_____ Yes ______ No
In Workshop 13, there is an optional task for creating a custom menu button for running a parameterless
macro.
Workshop 11-Mucros: Overview,,,
Macros: Overview 229
6 Do you think its possible to run the first macro (.my_zoomed_view) now that youve
recorded a new macro? ______ Yes ______ No
7 Write T or F to indicate which of the following statements are true or false.
____ You can only run the last default macro youve created.
____ Although the Execute Recorded Macro menu option only lets you run a macro named
record_macro, there are other ways to execute a macro.
____ You can run the macro by typing my_zoomed_view in the Command Window.
Workshop 11-Mucros: Overview,,,
230 Macros: Overview
Writing u purumeterIess mucro
As you saw earlier in the macro editor, the commands recorded can be verbose and perhaps
confusing. You can keep your macros concise, clean, and easier to read if you write them by
hand.
Create a tool for previewing parts by writing a parameterless macro that displays each part, with
a pause between each display operation, and then displays the model when it has finished.
To write u purumeterIess mucro:
1 From the Tools menu, point to Macros, point to Edit, and then select New.
The Create /View Macro dialog box opens. By default, the macro name field is MACRO_1.
2 If this macro were created, where do you think it would be stored in the database? Circle
one:
a) .gui.MACRO_1
b) .mdi.MACRO_1
c) .MACRO_1
d) .<default_model>.MACRO_1
If youre not sure where an object (macro, dialog box, variable, and so on) will be stored by
default, provide the absolute object name during creation (that is, .MACRO_1 instead of
MACRO_1).
3 Clear the Macro Name text box and enter .Preview_Parts
4 Clear the selection of Use Macro name.
5 Select Use Macro Name. Notice that it updates the Command text box with the desired name.
6 Check Yes for Wrap in Undo.
7 Enter the following commands in the Commands area.
for var=the_part object=(eval(DB_CHILDREN(DB_DEFAULT(.System_Defaults,"model"),"part")))
part display part=(the_part) fit_to_view=yes
pause
end !for
model display fit_to_view=yes
Tell the students where they can find the raw text for commands. They can cut and paste from
misc/shortcuts.txt.
Workshop 11-Mucros: Overview,,,
Macros: Overview 231
8 Select OK to create the macro.
9 Run the macro by entering preview at the command line.
10 Press Enter on the keyboard when the Pause dialog box appears (as shown below).
Notice that the advantage of using a macro is you now have a command you can use,
instead of needing to import a command file every time you want to perform a set of
commands.
11 Look in the Command Navigator. See if you can find the command for your macro.
12 Export the macro (using the Tools menu, pointing to Macro, and selecting Write), and name
the file Preview_Parts.cmd
Creuting u mucro by importing u fiIe
Now that youve written a parameterless macro by hand and learned that theyre nothing more
than command files, it is fairly straightforward to import them.
To import u mucro:
1 Create a parameterless macro from the command file task_1_decision.cmd you used in the
last workshop (Workshop 10Conditional Constructs and Loops on page 194).
s From the Tools menu, point to Macro, and then select Read.
Complete the dialog box as follows:
x Macro Name: .wing_tip_generate
x File Name: Browse to task_1_decision.cmd
x User Entered Command: marker generate wing_tip
x Wrap In Undo: yes
x Create Panel: no
2 Select OK.
3 Run the macro.
Tip: Use the User-Entered Command.
Workshop 11-Mucros: Overview,,,
232 Macros: Overview
4 Export the macro.
Tip: From the Tools menu, point to Macro, and then select Write.
5 Open the file in a text editor.
6 Do you notice anything that looks different?
The first line has a special entry, which is particular to macros. You will learn more about
that in the next Module (Macros: Syntax and Parameters on page 233).
7 Save your database.
8 Exit ADAMS/View.
OptionuI tusks
1 Create a parameterless macro from the file show_joint_and_parents_only.cmd.
2 The Preview_parts concept has been extended further to show a joint and its parents. It also
can animate the degrees-of-freedom (DOF) for the joint. To see it in action:
s Start a new database.
s Import the file completed/optional/test_model.cmd.
s Wiggle the joint DOFs by importing the file, constraint_DOF_wiggler.cmd.
s Open the file, constraint_DOF_wiggler.cmd to see how it was all accomplished using
ADAMS/View commands. Notice how important comments are in documenting your
work in a macro.
The DOF wiggler will also be covered as an optional task in Workshop 13Creating Custom
Menu Buttons on page 269.
Workshop 11-Mucros: Overview,,,
233
J2
MACROS: SYMTAX AMD PARAMTRS
Use the diskette transfer model and a customized Arc Toolkit. Run and write
macros.
Whut's in this moduIe:
s Parameters, 234
s Workshop 12Macros and Parameter Syntax,
241
234 Macros: Syntax and Parameters
Purumeters
Types
9eneruIized formut
Muming conventions
QuuIifiers und formuts
DefuuIt churucteristics
umpIes
Macros: Syntax and Parameters 235
Purumeters,,,
Types
s Real
s Integer
s File
s Object
s String
s List
9eneruIized formut
Muming conventions
QuuIifiers und formuts
DefuuIt churucteristics
umpIes
236 Macros: Syntax and Parameters
Purumeters,,,
Types
9eneruIized formut-
The general format of a parameter is $name:q1:q2:q3..., where:
s name is the name of the parameter.
s q1, q2, q3... are one or more qualifiers that specify the characteristics of the
parameter.
Muming conventions
QuuIifiers und formuts
DefuuIt churucteristics
umpIes
A discussion of how the macro is parsed twice can be found in KB8885.
Macros: Syntax and Parameters 237
Purumeters,,,
Types
9eneruIized formut
Muming conventions
s Must start with an alphabetic character.
s The rest of the name can include numeric characters and underscores (_) as well as
alphabetic characters (a-z, A-Z).
s The name ends at the first character that is not alphabetic, numeric, or an underscore.
Therefore, $P, $P1, and $PART_1 are valid parameter names while $PART#1 and
$1P are invalid.
s Not case sensitive.
s You use single quotes to explicitly separate the name or qualifiers from command
text immediately following the parameter.
QuuIifiers und formuts
DefuuIt churucteristics
umpIes
238 Macros: Syntax and Parameters
Purumeters,,,
Types
9eneruIized formut
Muming conventions
QuuIifiers und formuts
You can use qualifiers on the first occurrence of the parameter to control the parameter
characteristics.
s Qualifiers are optional.
s They can only be used the first time the parameter appears in the macro text.
s You can use the qualifiers in any combination and any order.
s If repeated, ADAMS/View uses the last value.
s Qualifiers are not case-sensitive.
Parameter can have one or more of the following qualifiers:
s Type
s Range
s Count
s Defaults
DefuuIt churucteristics
umpIes
Macros: Syntax and Parameters 239
Purumeters,,,
Types
9eneruIized formut
Muming conventions
QuuIifiers und formuts
DefuuIt churucteristics
s It is recommended that you explicitly set the characteristics of your parameters in
comments at the beginning of your macro.
s The first occurrence of a parameter in the command text defines the parameter
characteristics. This is true even if the first occurrence is in a comment.
umpIes
240 Macros: Syntax and Parameters
Purumeters,,,
Types
9eneruIized formut
Muming conventions
QuuIifiers und formuts
DefuuIt churucteristics
umpIes-
$cm_location_from_part:t=location:d=0,0,0
$excitation_mode:t=list(heave,pitch,roll,warp):d=heave
$error_variable:t=variable:d=.ACAR.variables.errorFlag
$number_of_steps:t=integer:gt=0
The qualifiers:
Specify that the parameter
requires:
$parts:t=part:c=2
Names for two existing parts.
$NSpokes:T=INTEGER:GE=3:LE=8:D=3 An integer from 3 to 8 and a constant
default of 3.
$infile:t=file(*.dat) File name. The File Selection dialog
box lists all files with the extension
.dat.
For more examples of parameters, refer them to the Automating Your Work Using Macros chapter
in the guide, Customizing ADAMS/View.
Macros: Syntax and Parameters 241
This workshop takes about one hour to complete.
ProbIem stutement
In Workshop 11Macros: Overview on page 223, you wrote parameterless macros that worked
well for specific purposes. However, you saw that parameterless macros have some limitations
because they dont allow data to be passed into them. In this workshop you will learn how to
write ADAMS/View macros that use parameters, allowing them to become general purpose
solutions and powerful tools for automating your work.
You will use the diskette transfer model and a customized Arc toolkit, and will run and write
macros that do the following:
s Create marker midway between two markers
s Swap markers from one part to another
s Replicate parts and offset them a prescribed distance along a given axis
s Create arcs and outlines that are tangent
XII I
II
III
IV
V VI VII
X
XI
VIII
IX
Workshop 1Z-Mucros und Purumeter Syntu
242 Macros: Syntax and Parameters
9etting sturted
To get sturted:
1 Start ADAMS/View from the directory, mod_12_macro_syntax.
2 Select Create a new model, using the default settings.
3 Create two markers on ground in two different locations in the window.
umpIe of u simpIe mucro
The online documentation has some basic macro examples. One of the macros, ex1_mar_mid,
will create a new marker midway between two existing markers that you specify. Lets look at
it closer to see how it works.
To tuke u cIoser Iook ut the mucro:
1 Import the command file, load_online_doc_macros.cmd.
This loads the macro (and a few other example macros) into the database.
2 Using the Command Navigator, select the ex1_mar_mid command.
ADAMS/View automatically generates the Ex1 Mar Mid dialog box. The text boxes
correspond to parameters in the macro.
3 Close the Command Navigator.
4 Run the macro as follows:
s First Marker: MARKER_1
s Second Marker: MARKER_2
s New Marker Name: midway
5 Select Apply.
ADAMS/View creates a marker named midway, halfway between the two markers you
specified.
Workshop 1Z-Mucros und Purumeter Syntu,,,
Macros: Syntax and Parameters 243
6 Display the macro commands that created the marker:
s From the Tools menu, point to Macro, point to Edit, and then select Modify.
s From the Database Navigator, select the macro .ex1_mar_mid.
7 Move the macro editor so it is alongside the Ex1 Mar Mid dialog box, so you can compare
its text boxes to the text in the macro editor.
8 Review the macro commands, noting the following:
A Three parameters (indicated by $ at the top of the macro) are used to pass in the data
you entered in the three text boxes.
B These parameters, have type qualifiers indicated by T=...; the type marker is different
from the type new_marker.
C The labels in the dialog box correspond to the naming of the parameters, without the
underscore and $ characters. Therefore, Second Marker corresponds to
$SECOND_MARKER.
D A new marker will be created at a location calculated from the database values of the
existing marker locations. It will have the name that is passed in through the
$NEW_MARKER_NAME parameter.
C
A
B
D
Workshop 1Z-Mucros und Purumeter Syntu,,,
244 Macros: Syntax and Parameters
9 Right-click the New Marker Name text box that currently contains the text midway, point to
Field Info, and then select Validate.
Notice that the text box turns yellow, and ADAMS/View issues a warning message. Here
you see the parameters type qualifier in action. The qualifier specified that parameter must
be a new marker, and since midway already exists, its no longer new and is, therefore, an
invalid choice. Now, if you want to create another marker between markers, you will have
to choose a unique name.
10 Close the Ex1 Mar Mid dialog box.
11 Display information on the midway marker you created and review its local location
expression.
((MARKER_1.loc_x + MARKER_2.loc_x) / 2),
((MARKER_1.loc_y + MARKER_2.loc_y) / 2),
((MARKER_1.loc_z + MARKER_2.loc_z) / 2)
Notice that the expression ($FIRST_MARKER.loc_x) in the macro has become
(MARKER_1.loc_x) after the data was passed through the macro.
Tip: Use the eval function in your macros to reduce an expression to literal values.
Now youve seen the structure of a basic macro. Lets write one by hand.
Writing u mucro to chunge the purent of severuI murkers-
Lets write a macro that will swap the parent of several markers from one part to another.
To write u mucro:
1 Delete the current model from the database:
s Close the macro editor.
s Select the Select tool so nothing is selected.
s From the Edit menu, select Delete.
The model is selected in the Database Navigator.
s Select OK.
ADAMS/View deletes .model_1.
You can demonstrate the Swap Parent macro by importing the file, ch_par_start_instructor.cmd in
the subdirectory, Misc.
Workshop 1Z-Mucros und Purumeter Syntu,,,
Macros: Syntax and Parameters 245
2 Import the command file named ch_par_start.cmd.
3 Display the Macro editor so you can create a new macro.
4 Clear the Macro Name text box by placing your cursor at the start of the text box and
pressing Ctrl-k.
5 Name the macro, mar_swa_par.
6 Clear the selection of Use Macro Name, and replace the command with: marker
swap_parent.
The command string you enter must be unique. You cannot redefine an existing command,
although you can add a new keyword at any level to an existing command. For example,
entering MARKER CREATE is invalid, because a MARKER CREATE command already
exists. Entering MARKER GENERATE is valid.
Part_3
Part_2
The markers
belong to
PART_2. You
will write a
macro that
swaps the
parent part to
Workshop 1Z-Mucros und Purumeter Syntu,,,
246 Macros: Syntax and Parameters
7 Set Wrap in undo to No.
You can specify whether or not the entire macro can be undone with a single UNDO
command. Note that UNDO, while convenient, may consume a great deal of memory for a
very large macro, or slow macro execution noticeably, even if you do not actually use the
UNDO.
Tip: You can check the memory usage of UNDO with the following command:
list_info undo write_to_terminal = on
To learn more about UNDO commands in general, open the Command Navigator, point to
undo, and then select HELP at the bottom of the window.
Now its time to construct the macro by entering text in the large Commands text box.
ADAMS/View does not check your entries in the commands box for correct syntax when
you create the macro, only when the macro is executed.
8 Enter the following parameters and commands:
!$marker:t=marker:C=1,0
!$new_parent:t=part
!$model:t=model:A
!END_OF_PARAMETERS
for variable=tmp_loop object=$marker type=marker
marker modify marker=(tmp_loop) &
new_marker_name=$model.($new_parent.name).(tmp_loop.object_value.name)
end
If the student is short on time, they can copy/paste text from misc/shortcuts.txt.
Workshop 1Z-Mucros und Purumeter Syntu,,,
Macros: Syntax and Parameters 247
Heres a description of what some of the key pieces do:
A The C=1,0 is a Count qualifier that specifies the number of values required. Here, it's
allowing one or more markers to be passed into the macro.
B The colon character is used to separate the various qualifiers for a parameter.
C The A is a database qualifier indicating that the automatic default is the current
default object, in this case the default model, .model_1.
D The FOR/END loop is operating on the set of objects passed in through the $marker
parameter. For each marker it will swap the parent from its current part to that which
is passed in through $new_parent.
E The new_marker_name is constructed in pieces. The use of parentheses is required
on some pieces because they are expressions (that is, accessing database values).
Here's a breakdown of each:
$model becomes .model_x
($new_parent.name) becomes PART_x
(tmp_loop.object_value.name) becomes MARKER_x
So the new_marker_name takes the form: .model_x.PART_x.MARKER_x.
You may want to demonstrate a common mistake: Try using !$END_OF_PARAMETERS, and show
how accidentally including a $ will make the dialog box have an additional field. Then, demonstrate how
you have to delete the dialog box so that it can be refreshed after the macro parameter is modified.
A
B
C
D
E
Workshop 1Z-Mucros und Purumeter Syntu,,,
248 Macros: Syntax and Parameters
Note: If the .name database operator hadnt been used on the $new_parent parameter,
the macro wouldnt have worked. Thats because the full part name would have
been expanded, and as a result, an unacceptable name would have been formed,
like this:
9 Select Apply.
ADAMS/View creates the macro.
Tip: For further discussion of macro parameters, the exclamation point (!),
END_OF_PARAMETERS, and more, refer to the Knowledge Base Article 8885,
available at: http://support.adams.com/kb/faq.asp?ID=kb8885.dasp.
10 Run the macro from the Command Navigator so that a dialog box is auto generated.
s From the Command Navigator, select marker, and then select swap_parent.
ADAMS/View displays the dialog box.
Notice how some text box backgrounds are white, while others are gray. This
distinguishes the required text boxes (white) from the optional ones (gray). Here, the
model parameter is optional because a default qualifier was specified in the macro that
auto generated the dialog box.
.model_x..model_x.PART_x.MARKER_x
When name isnt used
Model is repeated
Workshop 1Z-Mucros und Purumeter Syntu,,,
Macros: Syntax and Parameters 249
11 Enter the following:
s Marker: Browse and select the following markers on PART_2: MARKER_2, MARKER_3,
MARKER_4
s New Parent: Pick the blue part (PART_3) off the screen.
s Model: Leave it blank and it will use the default model.
12 Select Apply.
The markers now belong to PART_3.
If you had made any typographical mistakes, error messages would have been issued. This
is quite common as its difficult to type a macro without any errors, even with substantial
experience writing macros.
Even if your macro was successful, review the next section because it covers essential
information for developing your own macros.
Workshop 1Z-Mucros und Purumeter Syntu,,,
250 Macros: Syntax and Parameters
Modifying u mucro thut isn't working
Its important to know that an auto-generated dialog box grabs and stores the parameters from
the macro when it is initially generated. If you subsequently modify the parameters in the macro,
they are not automatically updated in the dialog box. Therefore, you must delete the auto-
generated dialog box and re-issue the macro from the Command Navigator so that
ADAMS/View will use the new macro parameters. If you only modify commands, you do not
have to delete and regenerate the dialog box.
To modify mucro purumeters und communds:
1 Delete the macro's auto-generated dialog box.
s From the Tools menu, point to Dialog Box, and then select Delete.
s At the bottom of the Database Navigator, select No Sort from the Sort Type option
menu.
s Scroll down until you see your dialog box name.
2 Select the dialog box you want to delete, that is, mar_swa.
Workshop 1Z-Mucros und Purumeter Syntu,,,
Macros: Syntax and Parameters 251
3 Select OK.
4 Modify your macro (using the macro editor) to correct the syntax errors.
5 Select Apply.
6 Access the macro command using the Command Navigator.
ADAMS/View generates a new dialog box.
7 Run the macro to see if your modifications have fixed the problem.
To modify communds onIy:
1 Modify your macro (using the macro editor) to correct the syntax errors.
2 Select Apply.
3 Run the macro to see if your modifications have fixed the problem.
porting u mucro
Once your macro is functioning the way you want it to, you should save it for future use.
Although you could save the database and the macro would be stored there, we dont
recommend it. It's a better idea to save your macros in ASCII (flat text) format, like a command
file. This will ensure successful upgrades from one ADAMS/View release to the next.
Because a macro is not the child of a model, it will not be written out when you export your
model as a command file. The macro export is done through its own command language.
To eport u mucro:
1 From the Tools menu, point to Macro, and then select Write.
s Macro Name: .mar_swa_par
s File Name: mar_swa_par.cmd
2 Review the exported macro in a text editor.
It should look similar, if not identical, to the way it did in the macro editor.
Workshop 1Z-Mucros und Purumeter Syntu,,,
252 Macros: Syntax and Parameters
Writing u mucro thut cuIIs unother mucro-
Because the macros you write become extensions of the ADAMS/View command language, it
is easy to begin using them just like any other command. For instance, you can write a macro
that calls another macro youve written. In this section, you will write a macro for making
multiple copies of a part and projecting them along the axis of a marker. The macro will achieve
this by calling another macro (for single replication) in a FOR loop so that it is executed
repeatedly. This is similar to how you copied the diskettes in Workshop 10Conditional
Constructs and Loops on page 194, but this time you will use a macro with parameters.
To write u mucro thut cuIIs unother:
1 Open a new database, and then import the command file, disk_start.cmd.
2 Save the database as disk.bin so you can quickly reopen it later.
3 Import the macro part_replicate_single_mac.cmd.
s From the Tools menu, point to Macro, and then select Read.
s Macro Name: par_rep_single
s File Name: part_replicate_single_mac.cmd
s Accept the defaults for the remaining text boxes, and then select OK.
Give the students a preview of what the macro will do by importing the file, batch_disk.cmd.
Workshop 1Z-Mucros und Purumeter Syntu,,,
Macros: Syntax and Parameters 253
4 Display the macro in the macro editor and review the commands used.
Items of special interest in this macro are:
A Use of a List type qualifier for $which_axis. This allows the user to choose from a list
of axes: x, y, and z. The default qualifier, D, has set the default value to Z. If the user
doesnt choose an axis, the z-axis will be used.
B Temporary local variables ($_self.tmp_mod, $_self.tmp_name) are defined up front.
This is good macro programming practice. They are often used to store a value or
object up front, such as the model name, so that you dont have to do a database
lookup or write a lengthy expression every time. Thats why $_self.tmp_mod is there.
In other cases, they are handy for prototyping out strings, such as message text or part
names. Here, the $_self.tmp_name is used to construct the name of the replicated
copy.
The $_self is often confusing at first glance, but is actually pretty straightforward. It is
now possible to create an ADAMS/View variable as a child of anything. This includes
macros. This is very useful when creating clean macros with variable names that make
sense. Overall, it cleans up the entire structure of the database.
A
B
C
D
Workshop 1Z-Mucros und Purumeter Syntu,,,
254 Macros: Syntax and Parameters
This is what $_self is if you were to think of it as a macro parameter defined at the top
of a macro:
So, $_self is the macro itself, and $_self.tmp_var is a variable whose parent is the
macro.
C Use of IF/ELSEIF/END logic to decide along which axis to project the copy.
D The cleaning up of local variables at the end of the macro by deleting both of them
with a simple wildcard, $_self.*.
5 From your directory, open the file, part_replicate_multi_partial_mac.cmd.
This file contains an incomplete version of the macro you need to write. The parameters
you need to use can be found in the commands but have not been properly qualified at the
top of the file.
!$_self:T=macro:A
Default
Workshop 1Z-Mucros und Purumeter Syntu,,,
Macros: Syntax and Parameters 255
6 Define the parameter qualifiers at the top of the file so they meet the following
requirements:
s You can only specify a single marker to project along.
s The distance to offset each replicate (that is, copy) is a real number with a default of
100.
s Maximum number of copies you can make with a single execution of the macro is 25
and the minimum is one. Use a default value of three copies.
s Let the z-axis be the default axis, but let the user choose from a list of three: x, y and
z.
7 Save your macro file as part_replicate_multi_mac.cmd.
8 Import the macro.
Tip: If you encounter errors and want to refresh the model, just open a new database and
choose the file, disk.bin, which you saved earlier.
9 Execute the macro you wrote so it makes three copies of DISK_1 offset 5 mm apiece
along the z-axis of the diskettes center-of-mass.
s In the Command Navigator, select part, select replicate, and then select multi.
s Marker_to_project_along: .model_1.DISK_1.cm
s Offset_distance: 5
s Number_of_copies: 3
s which Axis: z
Workshop 1Z-Mucros und Purumeter Syntu,,,
256 Macros: Syntax and Parameters
10 Select OK.
The DISK_1 part has been successfully replicated three times.

If the students try to run the model as is, the disk replicates will just fall, due to gravity. Therefore they
must use fixed joints to prevent them from falling. The kb6607 has a parameterless macro for locking parts
to ground. They can access it in the subdirectory from_kb/fixed_jnt_selected_parts.
Workshop 1Z-Mucros und Purumeter Syntu,,,
Macros: Syntax and Parameters 257
umpIe of how to orgunize u suite of mucros
Sooner or later you will have written enough macros that keeping them organized will be a task
in and of itself. Lets look at one approach you could use to organize a suite of macros.
Several versions ago, one of the application engineers at the MDI office in Germany had
assembled many of his macros and packaged them together for internal use as the TK_toolkit.
Since then, ADAMS/View has changed quite a bit, making many of the macros in the toolkit
obsolete. However, there are still some very useful gems: a fine set of examples from which you
can harvest tricks, expand your understanding of macro syntax usage, and see some creative
ideas.
The Arc TooIkit eumpIe
A large portion of the macros in the TK_toolkit dealt with the creation of arc geometry. Here
weve taken that subset of macros and grouped them together in a custom interface window,
complete with its own set of menus, and called it the Arc Toolkit.
Workshop 1Z-Mucros und Purumeter Syntu,,,
258 Macros: Syntax and Parameters
To orgunize u mucro:
1 Open a new database, and select Create a new model.
2 Draw a simple arc on ground (using the Main Toolbox).
3 Load the Arc Toolkit by importing the command file, custom_window_start.cmd.
Notice that it displayed the standard toolbar, which appears beneath the Main menubar, as
shown in the previous figure.
4 To display the Arc Toolkit, from the standard toolbar, select the Arc Toolkit icon .
5 Browse through the menus to see the variety of choices available. Behind each menu
push button is a separate set of macro commands.
6 Select one of the menu buttons and fill in the text boxes in the dialog box accordingly.
7 Pick one or two of the macros and review their commands in the macro editor.
Hint: You can find the macros inside the library, my_cust.
Do you notice anything different about the macro(s)? One big difference is that $_self was
not used. Why? Because it didnt exist back when the macros were originally developed.
Keep that in mind when you review these or any other macros, because some of the
techniques used may be a bit dated when judged against the latest standards or available
commands and features.
Using u buiId fiIe
When you imported the file that built the Arc Toolkit, the building was being done in a creative
way. All of the macros for the Arc Toolkit are in a separate subdirectory. An environment
variable stores the path. When the build file is imported, it uses the value of the environment
variable to know where to look for the macros. Here youll learn more about how it was done.
Workshop 1Z-Mucros und Purumeter Syntu,,,
Macros: Syntax and Parameters 259
To use u buiId fiIe:
1 Open the custom_window_start.cmd file in a text editor.
A
B
C
D
E
Workshop 1Z-Mucros und Purumeter Syntu,,,
260 Macros: Syntax and Parameters
2 Review the general structure of this build file. (We refer to it as a build file because it
builds the toolkit.) Here are the primary sections:
A The PUTENV design-time function is used so that the environment variable tk_tools
is set to the directory path where all of the macros reside. (Setting the environment
variable using a command in this fashion is optional. Although you must set the
environment variable for the macros to load properly, it is not necessary to set it with
this command. You could set it directly in a UNIX or DOS shell, if you prefer.)
B An ADAMS/View library is created, which acts as a repository for all the
customizations of the Arc Toolkit, such as macros and menus. This keeps the
database organized so that everything customized is isolated from the standard
interface objects.
C ADAMS/View reads the macros into the database and stores them in the library,
.my_cust. The path to each macro file is constructed by getting the value of the
environment variable and concatenating that string with the known path beneath the
known macros subdirectory structure.
D An interface window, menubar, and menus are created.
E Menu push buttons are defined, with each having an underlying macro command.
You will learn more about D and E in Workshop 13Creating Custom Menu Buttons on
page 269.
This is one approach for building a suite of customized macros. You might consider doing
something similar with the macros you develop.
You have learned to write macros. You can find more information about the syntax in the
online documentation.
Workshop 1Z-Mucros und Purumeter Syntu,,,
Macros: Syntax and Parameters 261
Other resources
This workshop contains a few macros from the Knowledge Base. You can find the macros in
the subdirectory, from_kb. Some of the subdirectories are:
s contact_site - Contains a macro, cont_site_mac.cmd, for visualization of the site of
contact. This is a good example of how to use comments in your macro for
documentation purposes.
s fixed_jnt_selected parts - Contains two macros for creating fixed joints for every part
that is on the select list.
s geometry_select_only - Contains a menu button that uses a parameterless macro to
loop through all the parts on the select_list and find the immediate children that are of
type=geometry. Then, it empties the select list and replaces it with those geometries
that it found. It also displays the select list manager so you can remove some
geometry from the list.
s line_of_markers - Contains a macro, line_of_markers_mac.cmd, that uses a FOR loop
to generate a number of new markers equally spaced along the line between two
existing markers. All new markers will automatically belong to whatever part is
currently the default and will be given unique names like MAR_1, MAR_2, and so on.
The new markers will all have their primary axis (which is the z-axis, by default)
pointing from the first marker toward the second marker.
s list_inactive_objects - Contains a macro, check_if_inactive.mac, that will loop
through parts, forces, and joints in a model. When it finds an object that has attributes
of active=off, it will put it inside a group. This group of objects will be listed later in
the Information window when the macro finishes running.
s solver_curve_to_polyline - Contains a macro, curve2poly.mac, that will convert an
ADAMS_curve entity to a Polyline entity. All you have to do is specify the curve that
you want converted and the marker representing the reference frame for the data. The
polyline will be created and will belong to the parent of the marker specified.
For more information, see the ADAMS Knowledge Base, located on the support site (http://
support.adams.com). To find macros, use the keyword macro or perform boolean searches like
macro* and joint or macro* and beam.
Workshop 1Z-Mucros und Purumeter Syntu,,,
262 Macros: Syntax and Parameters
Several older macros, from version 8.2, are on the CD in the directory, old_v8_macros. This
directory contains many macro examples that were shipped with version 8.x (as mentioned in
kb6660). None of the macros provided there have been updated for release 9.x or beyond. In
fact, its possible that the functionality provided by a given example may now be superseded by
standard ADAMS/View features. Regardless, they represent an assortment of examples from
which you can improve your understanding of syntax and expressions, and what you can do
with the macro language in general. See the file, readme.txt, in that directory for a list of the
macros available.
The macros are provided on the CD for this training course on an "as is" basis.
OptionuI tusks
1 Write a macro that creates markers at every vertex of a given polyline. Use either a
FOR/END or a WHILE/END construct.
2 Write a macro, poly_2_outline_mac.cmd, that converts polyline geometry to outline
geometry.
3 Review the commands for the macro that was used to sweep the value of a design
variable. You can find the macro, var_swe_mac.cmd in the subdirectory, DV_sweep.
4 Write a macro, cre_imp_sfo_mac.cmd that creates an impact SFORCE from two markers,
and the IMPACT function parameters: stiffness, damping_coefficient, and free_length.
For simplicity, for this example, hardcode the exponent to 1.0 and the penetration to 0.1.
5 Write a macro, display_joint_mac.cmd, that displays a joint and its parent parts.
6 Try out the macro, tra_swe_btw_mar_mac.cmd, which can sweep the animation trace in
ADAMS/PostProcessor from one marker to another.
Workshop 1Z-Mucros und Purumeter Syntu,,,
263
J3
MMUS
Learn how to create new menu buttons on the main menu bar, as well as your
own menu bar.
Whut's in this moduIe:
s Menu Builder, 264
s Syntax of Menu File, 265
s Using Commands to Add Menus, 268
s Workshop 13Creating Custom Menu Buttons,
269
264 Menus
Menu uiIder
Overview-
s You can use the Menu Builder to modify and create menus to better suit your needs
and preferences, or match your industrys terminology.
s You can specify keyboard accelerators (shortcuts) and mnemonics.
s You can build menus for a particular model or for an entire application. You can add
the elements shown in the following figure:
Mention to the students that the interface terminology used in the ADAMS command language may not
match the terms found in the online documentation.
Menu
Button
Button
Menus 265
Syntu of Menu FiIe
s Each line of a menu file defines an object and its name, or specifies information about
the parent object. For clarity, ADAMS/View indents the lines. As you edit the text,
you can also indent the lines.
s The following figure shows a portion of the Menu Builder that defines the Help menu
in ADAMS/View. To the right of the Menu Builder is the corresponding Help menu
as it appears in ADAMS/View.
266 Menus
Syntu of Menu FiIe,,,
Menu
MENUn TITLE
NAME=name
HELP=Help
utton
BUTTONn LABEL :: ACCELERATOR
NAME=name
HELP=help
CMD=command
Sepurutor
SEPARATORn
ToggIe
TOGGLEn TITLE
NAME=name
HELP=help
STATE=state
CMD=command
Menus 267
Syntu of Menu FiIe,,,
s The text lines have the following parameters:
x n is an integer between 1 and 10, usually 1, 2, or 3. It defines the menu level
in which the object appears. Level 1 is the first level. MENU1 appears on the
menu bar, for example, while BUTTON2 appears under the preceding MENU1.
The n is required for MENU, but is optional for the other objects. If you omit
the level, ADAMS/View assumes the object belongs under the last MENU.
x You can cascade menus up to 10 deep by nesting MENUs below other
MENUs. You can include as many buttons in a menu as you want, although
you should not create more than will fit on your screen.
x label is the text that appears in the menu. For an icon button, you specify the
icon name instead of the text. In Motif, the icon name is the name of a XBM
(X BitMap) or XPM (X PixMap) format file. In Windows, the icon name is
the name of a bitmap (.bmp) format file.
268 Menus
Using Communds to Add Menus
If you want to modify the ADAMS/View main menu, it is highly recommended to do this using
commands instead of the Menu Builder, or .mnu file.
Menus 269
This workshop takes about one hour to complete.
ProbIem stutement
In this workshop you will learn how to create new menu buttons on the main menu bar, as well
as your own menu bar. You will become familiar with the ADAMS/View command language
for creating these interface (GUI) objects and will become comfortable with using the Menu
Builder.
9etting sturted
To get sturted:
s Start ADAMS/View from the directory, mod_13_menus, and then select Create a New
Model.
Demonstrate the menu editor by setting the following menu accelerators for macro record/replay:
Record Start : : F10
Record End : : F11
Execute : : F12
XII I
II
III
IV
V VI VII
X
XI
VIII
IX
Workshop 13-Creuting Custom Menu uttons
270 Menus
Adding new menu buttons to the muin menu bur
You can add your own menus and push buttons onto the main menu. How you do this will
depend on the extent of the changes you want to make. Sometimes, if you are making several
menu modifications, youre better off creating your own interface window and a separate menu
structure on that window. Thats how the Arc Toolkit from Workshop 12Macros and
Parameter Syntax on page 241 was done, for example.
If youre just making a few minor changes to a menu, the easiest way to do that is with the Menu
Editor. In other instances, you may prefer to write the command language in a command file
that you can import.
Modifying the muin menu using the Menu uiIder
If creating a marker using the Main Toolbox doesnt give you all the versatility you want, you
can access the Command Navigator and use the Marker Create and Marker Modify dialog boxes
instead. Lets make those features more convenient by creating a Marker New and Marker
Modify push button on the Build Menu as shown next:
To modify the muin menu:
1 From the Tools menu, point to Menu, and then select Modify.
The Menu Builder appears.
Move it aside slightly so it will be visible even if it were to go behind the main window.
Workshop 13-Creuting Custom Menu uttons,,,
Menus 271
2 Scroll about half-way down to where you see this portion of the menu text outline.
3 Place your cursor at the end of the last line of the highlighted text shown above.
Place your cursor here
Workshop 13-Creuting Custom Menu uttons,,,
272 Menus
4 Press Enter, and then type in the following text outline:
MENU2 Mar&ker
NAME=marker
BUTTON3 &New...
CMD=int com com="marker create"
HELP=Create a marker by using a dialog box
BUTTON3 &Modify...::Ctrl+M
NAME=modify_button
CMD=int dia dis dia=.gui.mar_mod
HELP=Modify an existing marker
Your window should look as shown next:
Tip: Placing an & in the label identifies that the next character will be used as the
mnemonic (for example, enter &New to have the resulting menu command be New.)
If the students are short on time they can cut/paste the text from the file misc/shortcuts.txt
Workshop 13-Creuting Custom Menu uttons,,,
Menus 273
5 To execute the changes to the menu, from the Menu Builder window, select the Menu Bar
menu, and then select Apply.
6 In your ADAMS/View window, look in the Build menu to verify that your new buttons
are in the Build menu. Test them out. Notice that the status bar displays the help text that
you entered for each push button.
Suving the chunges to u menu
To suve chunges:
1 Display the Menu Builder again.
2 From the Menu Bar menu, select Export Text.
3 Save the file as main.mnu.
The menu text outline has been saved to your local directory.
4 In the Menu Builder, from the Menu Bar menu, select Exit.
Restoring the customized menu
To restore the menu:
1 Open a new database (without saving changes), and create a new model.
2 Select the Build menu and look at the menu buttons.
3 Are your customizations there? ____ Yes ____No
4 To load your customized menu into the database, from the Tools menu, point to Menu, and
then select Read Local Main Menu.
5 Check the Build menu again, this time you will see the custom buttons.
Tip: Try executing the marker modify with the keyboard accelerator shortcut, Ctrl-m.
Note: The file must be named main.mnu in order for it to be loaded by the Read Local
Main Menu button. Also, ADAMS/View will only look in the local directory (the
directory where you started ADAMS/View, or the current directory as set by File -
Select Directory).
6 If you want to load a menu file that has a different name, from the Tools menu, point to
Menu, and then select Read.
Workshop 13-Creuting Custom Menu uttons,,,
274 Menus
Other feutures of the menu buiIder
Experiment with the Menu Builder features to get a feel for what they do. Then, complete the
quiz below.
Quiz:
Draw a line to match items in the left column with choices in the right column:
1 Repopulates the text Menu Builder
with the state of the current menu.
2 Writes the text outline for the menu to
a text file.
3 Imports text from a file into the
current position of the cursor.
4 Takes the text outline and applies it,
thus modifying the menu structure
5 Exits the Menu Builder
6 Take a menu existing in the database
and load it into the Menu Builder.
Load
Apply
Reload
Import Text
Export Text
Exit
Workshop 13-Creuting Custom Menu uttons,,,
Menus 275
Modifying the muin menu bur by writing commund Iunguuge
In Workshop 6Performing a Design Study on page 121, you used a custom menu button (and
macro) to sweep the value of a design variable. You would probably agree that using a button
on the menu is often simpler than traversing through the multitude of commands available in
the Command Navigator. Here you will learn how to create a menu button by writing the
command language directly. This alternate approach is helpful because it gives you an
organized way to reconstruct a customized menu structure.
To modify the muin menu bur:
1 Start a new database and import the file, load_the_sweep_macro.cmd.
ADAMS/View loads the sweep macro into the database where it will be stored with the
name, .var_swe.
Notice that ADAMS/View does not have a model in the database, as indicated by the title
text in the upper left corner of the view window. Since you will be modifying the interface,
it is not necessary to have a model open.
2 What is the command prefix for this macro? ____________________________________
Hint: Look in the Command text box in the macro editor.
ADAMS/View can auto generate a dialog box for this macro when you supply it with the
command prefix you wrote above.
3 Execute the following command from the Command Window and it will auto generate
and display the dialog box for the sweep macro.
interface command_builder command_prefix = "variable sweep"
This is the command you should put behind the button, to display the dialog when you click
the button.
4 Now compare the following commands:
interface command_builder command_prefix = "variable sweep"
interface dialog_box display dialog_box_name = .gui.var_swe
Workshop 13-Creuting Custom Menu uttons,,,
276 Menus
5 We had you type the first command instead of the second one for a reason. See if you can
identify the best reason from the choices below: (check one)
____ They are equivalent and you need to learn all the different ways of displaying a dialog
box.
____ The first command has fewer parameters and would be easier to type.
____ The dialog box .gui.var_swe doesnt yet exist. You cant ask the code to display a
dialog box if it hasnt been created first.
____ They have the same number of characters so the reason for choosing one command
over the other is irrelevant.
6 Close the Variable Sweep dialog box.
Workshop 13-Creuting Custom Menu uttons,,,
Menus 277
Reviewing the menu hierurchy
Here youll create a button named Sweep under the Build menu. Let's see the hierarchy of that
menu so we know where to place the new button.
To review menu hierurchy:
1 Use the Database Navigator to see the structure of the menu hierarchy.
s Open the Database Navigator.
s At the bottom, to the right of the Filter text box, choose All from the option menu. This
will allow the GUI objects, like menus, to be shown. The GUI objects are normally
filtered out.
s Expand the gui library and navigate as shown next:
Note: You may have to widen the Database Navigator to see the object type.
2 Select Design_Variable_select.
3 Select OK.
Workshop 13-Creuting Custom Menu uttons,,,
278 Menus
4 In the Information window, ADAMS/View displays information about that GUI object,
.gui.main.mbar.build.Design_Variable.Design_Variable_select.
5 Review the text in the window and circle the best answer, True or False:
T F The object is a menu.
T F The parent of the object is a Graphic_Interface_Menu.
T F A menu button cannot execute more than one command with a single click.
T F The parent of the object has two children. (Hint: use the Parent and Children
buttons in the info_window).
T F You will soon create a Graphic_Interface_Push_Button that will be a sibling of
Design_Variable_New and Design_Variable_select.
Workshop 13-Creuting Custom Menu uttons,,,
Menus 279
Workshop 13-Creuting Custom Menu uttons,,,
Creuting your own button
To creute your own Sweep button:
1 Open the file load_the_sweep_macro.cmd in a text editor.
2 Scroll down to the section of comments shown here:
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
! INSERT YOUR COMMANDS FOR CREATING PUSH BUTTON BELOW
!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
3 Modify the file so it can create the menu push button by entering the following command
language in the space provided.
Here, the backslash is used as an escape character, allowing the quotation mark characters
to be seen as literal characters, instead of as the closing quotation mark of the interface
command.
4 Save the file as load_the_sweep_macro_and_button.cmd.
Now youre ready to test the command file to see if it loads the macro and creates the menu
push button.
interface push create &
push_button_name=.gui.main.mbar.build.design_variable.Design_Variable_Sweep &
label = "Sweep..." &
help_text = "Sweeps the value of a design variable through its absolute range" &
command = "interface command_builder command_prefix = \"variable sweep\" "
280 Menus
5 Import the command file you just created.
6 Import the hood model from Workshop 8Optimization on page 158 that has been
parameterized with design variables.
7 Find the new menu button and select Sweep.
The Variable Sweep dialog box should open.
8 Sweep the D1 variable.
You have learned the two different ways of creating customized menu buttons. For more
practice, if time permits, complete the following section.
Understunding the structure of menu bur on u customized window
In Workshop 12Macros and Parameter Syntax on page 241 you used the Arc Tools custom
menu. Lets briefly review how it was created.
To eumine the structure of u menu bur:
s Open the file, custom_window.cmd. Briefly note the following items listed in sequential
order:
a The tk_tools environment variable is set to the appropriate path to the macro files.
b A custom library named my_cust is created.
c Several macros are imported and stored in the .my_cust library.
d An interface window named arc_toolkit is created in the .my_cust library.
e A menubar, menus, and push buttons are created. The push buttons issue the
macro commands for the macros that were imported.
f An icon is created on the standard toolbar.
Workshop 13-Creuting Custom Menu uttons,,,
Menus 281
Adding u push button to u custom window menu
To udd u push button:
You need to add two buttons to the Arc Tools menu, Simple Arc, and Swap Parent.
1 Start ADAMS/View and import the file custom_window.cmd.
2 Display the standard toolbar:
s From the View menu, point to Toolbox and Toolbars, and then select Standard Toolbar.
s Close the Tool Settings dialog box.
3 Select the Arc Toolkit tool .
The Arc Toolkit window opens:
4 Select the Create Arc menu, and notice that there are four push buttons listed.
You need to add another one named Simple Arc.
5 Use the Menu Editor to add the following button to the top of the Create Arc menu.
The procedure is similar to the one you used to modify the main menu in Modifying the
main menu using the Menu Builder on page 270.
Hint: Use Load and browse the menu in .my_cust.
BUTTON2 S&imple Arc
NAME=Simple_Arc
CMD=interface window undisplay window_name = .my_cust.arc_toolkit
CMD=interface command_builder command_prefix = "geometry create curve arc"
CMD=interface window display window_name = .my_cust.arc_toolkit
6 Test your button. Is the proper dialog box displayed?
7 Save the menu as arc_toolkit.mnu.
Consider the repercussions of using both the menu file and the custom_window.cmd file that
built the Arc Toolkit.
Perhaps the command file to build the Arc Toolkit could be rewritten so it just imports the
.mnu file. Do you think it's possible to write a command like that?
8 See if you can find a command that would do that, and write it here:
______________________________________________________________
Mention in passing that there has been an 'Easter Egg' hidden in the Arc Toolkit. If you double-click the
arc head icon a certain number of times you may see something special happen.
Workshop 13-Creuting Custom Menu uttons,,,
282 Menus
Chunging the hierurchy of un eisting menu
The Menu Builder lets you insert menus and buttons anywhere you like within the hierarchy.
Conversely, when you make changes to a menu using command language, instead of the Menu
Builder, there is a small downside: your changes will always be added to the bottom of an
existing menu. This is because the order of creation dictates the placement on the menu. That
explains why the Design Variable Sweep button was listed under New and Modify, whereas the
Marker custom menu did not end up at the bottom of the Build menu.
Therefore, if youre making small changes in hierarchy using command language, your strategy
might be to delete (or modify) a menu and to replace it with another, which will of course appear
at the bottom of the given menu.
Removing u push button
In this section, you will remove a push button and replace it with a menu and two push buttons.
As you recall from Workshop 8Optimization on page 158, optimizations will create verbose
output in the Command Window and in the file, aview.log. Eventually you may want to clear
out the log file so its not so big.
In this section, you will create a new menu entry that will clear the contents of the file,
aview.log. This will replace the Log File menu button with a new hierarchy:

By the way, kb9046 contains this method of clearing the log file.
After
Push
buttons
Menu
Push
button
Before
Workshop 13-Creuting Custom Menu uttons,,,
Menus 283
To remove u push button:
1 Using a text editor, open the file, test_menu_button_start.cmd.
2 Review the commands for:
s Deleting a push button
s Creating a separator line
s Creating a new menu entry
s Creating two new push buttons
Notice how the last push button just imports a command file named testit. This trick is a
clever way of changing the commands of a push button without manipulating the menu
editor, as you are debugging the logic in the underlying code.
In this case, the testit command file merely issues a message to the screen that the button is
working.
3 Import the file, test_menu_button_start.cmd.
4 Test the menu structure for the log file by selecting the new menu push buttons.
When you clear the log file, youll get the following message:
5 Rename the file testit.cmd to testit_0.cmd.
6 From the Tools menu, select Log File, and then select Clear Log File.
7 Did you get the error shown below? ____ Yes ___ No
ERROR: ADAMS/View could not open Command file testit.cmd for reading.
When you attempt to clear the log file, its trying to read a command file that's no longer
there.
8 Create a new file named testit.cmd by copying the file named testit_clear.cmd.
Workshop 13-Creuting Custom Menu uttons,,,
284 Menus
9 From the Tools menu, point to Log File, and then select Clear Log File.
The button works, and displays the following window:
10 Select one of the buttons.
11 Exit ADAMS/View.
Given this scenario of using a button to import a command file that you are debugging, you
would eventually need to put the commands behind the button. You would need to change
the button command from file command read... to the true set of commands. You can find
the completed button syntax for the above example in the file, clr_log_file_menu.cmd in the
subdirectory, from_kb/clr_log_file_menu.
Workshop 13-Creuting Custom Menu uttons,,,
Menus 285
OptionuI tusks
1 Learn some of the other interface commands by importing the file misc/
other_interface_menu_commands.cmd.
2 As you develop design objectives and design constraints (prior to running an
optimization) you often want to evaluate them for a given analysis. Use the customized
buttons in kb7917 to create the following new menu buttons:

3 Create a menu push button named Preview Parts at the bottom of the View menu. Use any
method you want to create the push button, but make it use the commands contained in
the file misc/preview_parts.cmd.
Continue with the optional tasks on the next page.
If the KB is not accessible, they can use the file, eval_menu_buttons_full_errchk.cmd in the
from_kb/obj_eval_menu subdirectory.
Create these entries
Workshop 13-Creuting Custom Menu uttons,,,
286 Menus
4 Using the Read Command File button on the Tools menu as a guide, create a menu button,
called Run Parameterless Macro on the Tools menu, which can be executed with a keyboard
accelerator (F12 key).
Hint: To learn more about accelerator key syntax review the online documentation about
menus.
BUTTON2 Run Parameterless Macro::F12
NAME=run_paramless_macro
CMD=! Note: F12 shortcut uses this
CMD=var set var=$_self.tmp_mac object=(eval(SELECT_OBJECT(DB_DEFAULT(.System_Defaults, "model").parent, "*" , "Macro" )))
CMD=var set var=$_self.tmp_str string=(eval(EXECUTE_VIEW_COMMAND(STR_DELETE( (my_macro.object_value),1,1))))
CMD=var del var=$_self.*
Test the button by running a recorded macro as well as the parameterless macro,
constraint_DOF_wiggler.cmd. For more information on parameterless macros, see Writing a
parameterless macro on page 230.
5 Create a menu button that will revolve a model about the screens y-axis in 100
increments, 3.6 degrees each. Use the file, revolve_the_model.cmd in the directory,
misc/revolve as the source for your commands.
Workshop 13-Creuting Custom Menu uttons,,,
287
J4
DIALO9 OXS
Create a dialog box that modifies the x and y coordinate locations of points 1,
2, and 4 of the disk transfer linkage.
Whut's in this moduIe:
s GUI Overview, 288
s Terminology, 289
s Working with Dialog Boxes, 290
s Dialog Box Builder Overview, 294
s Dialog Box Commands, 297
s Dialog Box Database Storage, 298
s Workshop 14Working with Dialog Boxes, 299
x Module review, 316
Show the Design Evaluation Tools dialog box as an example of a customized dialog box.
288 Dialog Boxes
9UI Overview
Dutubuse hierurchy for gruphicuI user interfuce {9UI} obgects
Window Dialog box
Container
Button stack
Label
Field
Button
Toggle button
Separator
Slider
Option menu
Radio box
Menu
Menu bar
Library
Sub-menu
Button
Toggle button
Separator
Pop-up
menu
Toolbar
All default objects stored
in .gui library.
Dialog Boxes 289
TerminoIogy
DiuIog o und its chiIdren obgect terminoIogy-
Weve been saying dialog box a lot during this course. Lets look at the examples here to make sure were
using the same terminology.
Label
Field
Option
menu
Radio
button
Button
stack
Dialog box
Button
Separator
Slider
Toggle button
Container
290 Dialog Boxes
Working with DiuIog oes
Modifying eisting pre-buiIt diuIog boes
Modifying diuIog boes thut were uuto generuted using mucros
Creuting diuIog boes from scrutch using the DiuIog o uiIder
Dialog Boxes 291
Working with DiuIog oes,,,
Modifying eisting pre-buiIt diuIog boes
Modifying diuIog boes thut were uuto generuted using mucros
Creuting diuIog boes from scrutch using the DiuIog o uiIder
Pre-built dialog box is:
.gui.geometric_panel
New dialog box is:

.gui.geometric_panel (not recommended)
or
.my_cust.geometric_panel
custom
button
292 Dialog Boxes
Working with DiuIog oes
Modifying eisting pre-buiIt diuIog boes
Modifying diuIog boes thut were uuto generuted using mucros
Creuting diuIog boes from scrutch using the DiuIog o uiIder
Dialog Boxes 293
Working with DiuIog oes
Modifying eisting pre-buiIt diuIog boes
Modifying diuIog boes thut were uuto generuted using mucros
Creuting diuIog boes from scrutch using the DiuIog o uiIder
294 Dialog Boxes
DiuIog o uiIder Overview-
Accessing the DiuIog o uiIder-
OperutionuI modes for renuming reshuping und modifying
Open obgect in DiuIog o uiIder
diting open obgect
diting chiIdren obgects of open obgects
The Title is special. It indicates the open object.
The object shown in the attributes indicator area is not necessarily the same as (a) the open object, or (b)
the selected object. An instructor demo here is necessary.
Title
Attributes type
selector
Dimensioning
and positioning
toolbar
Attributes
indicator
Attributes
area
Dialog Boxes 295
DiuIog o uiIder Overview,,,
Accessing the DiuIog o uiIder
You can access the Dialog Box Builder in one of two ways:
s From the Tools menu, point to Dialog Box, and then select Create or Modify.
s Double-click on a dialog box.
x For security reasons, this method is disabled by default.
x You can enable this feature by either:
x Modifying or creating a dialog box for the first time
x Setting the environment variable MDI_AVIEW_CUSTOMIZE=enabled
OperutionuI modes for renuming reshuping und modifying
296 Dialog Boxes
DiuIog o uiIder Overview,,,
Accessing the DiuIog o uiIder
OperutionuI modes for renuming reshuping und modifying-
Open obgect in DiuIog o uiIder
s Name of open object is displayed in title.
s You can only modify characteristics (size, name, attribute) of the open object and/or a
direct child object. In other words, you cannot modify a grandchild directly.
s Limited to dialog boxes, containers, and windows.
s Open objects using Dialog Box Open menus.
diting open obgect
s Use the Dialog Box menu to rename, fit, or edit its attributes.
diting chiIdren obgects of open obgects-
s Double-click the object with the left mouse button (notice that the attributes indicator
changes).
OR
s Select the object you want to modify:
x Single-click on an object with the left mouse button, or
x From the Edit menu, point to Select, and then browse for the object in the
Database Navigator.
THEN
s Use the Edit menu to rename, resize, or edit its attributes.
Emphasize that this is tricky, and that you need their full attention.
Consider showing a tree structure to describe the editing children objects concept.
Dialog Boxes 297
DiuIog o Communds
Sturt
s Commands are executed when object is displayed.
s Useful in initializing settings and putting default values into fields when object is
displayed.
ecution
s Commands are executed by the dialog box when the user clicks OK or Apply.
Finish
s Commands are executed when object is not displayed.
s Allows you to clean up work when object is not displayed.
298 Dialog Boxes
DiuIog o Dutubuse Storuge
isting 9UI obgects
Mew 9UI obgects
s It is highly recommended that you place all new objects in a user-created library.
s Objects placed in the .gui library will not be upward compatible!
All dialog boxes are placed in
this library, by default.
Dialog Boxes 299
This workshop takes about one hour to complete.
ProbIem stutement
Create a dialog box that modifies the x and y coordinate locations of points 1, 2, and 4 of the
disk transfer linkage.
9etting sturted
To import the modeI:
1 Start ADAMS/View from the mod_14_dboxes_I directory.
2 Import the model, disk_start_2.cmd.
XII I
II
III
IV
V VI VII
X
XI
VIII
IX
Workshop 14-Working with DiuIog oes
300 Dialog Boxes
Creuting u Iibrury
We recommend that you store all of your customized objects (macros and dialog boxes) in a
user-created library at the top level in the database. This will allow you to more easily access
these objects for future use. Also, the database will be more organized regarding your
customization objects versus what is included in the standard ADAMS/View database.
To creute u Iibrury:
1 From the Command Navigator, select library, and then select create.
2 From the Library Create dialog box, create a library named .my_cust.
Be sure to include the period (.) in .my_cust when entering the name of the library. If you
omit it, the library is stored as .materials.my_cust in the database (by default).
If you want to verify that the library was created, search the database using the Database
Navigator. Be sure that the filter is set to All.
Creuting u mucro
Here you will create a macro that modifies the point locations, which are currently defined using
ADAMS/View variables.
To creute u mucro:
1 From the Tools menu, point to Macro, point to Edit, and then select New.
The Create/View Macro dialog box opens.
2 In the Macro Name text box, enter .my_cust.modify_locations.
3 Enter modify_locations in the Command text box using one of the following methods:
s Uncheck the Use Macro Name checkbox and enter modify_location directly in the
Command text box.
s Clear the Use Macro Name checkbox, and then select it again so that the read-only text
in the Command text box is indicative of what it will really use.
When Use Macro Name is toggled on, which is the default, the ADAMS/View
command will be the short (not absolute) name of the macro, which is
modify_locations.
Workshop 14-Working with DiuIog oes,,,
Dialog Boxes 301
4 Set Wrap in undo to Yes.
This means that a subsequent Undo will undo all commands in the macro, instead of just
the last one in the macro.
5 In the Commands area, enter the following:
s Parameters:
x Names: P1_X, P1_Y, P2_X, P2_Y, P4_X, P4_Y
x Type: real
x Defaults: Use constant default values based on the current values of these
coordinates, currently defined via ADAMS/View design variables.
x Count: 1
s ADAMS/View Commands used:
variable modify variable_name=DV_p1_x real_value=$p1_x
variable modify variable_name=DV_p1_y real_value=$p1_y
You might want to create the body of the macro in a text file using a text editor, and
then paste the information into the Create/View Macro dialog box when you're ready.
This may help you with debugging.
Tip: If you are having difficulties, see the macro commands in Macro for Workshop 14
on page 352.
6 Select OK.
If the students are short on time, have them copy the macro commands from misc/shortcuts.txt.
Workshop 14-Working with DiuIog oes,,,
302 Dialog Boxes
DispIuying uuto-generuted diuIog bo und test the mucro
Here you will display the dialog box generated by the macro you just created. You will then test
the macro.
To test the mucro:
1 From the Command Navigator, find the user-entered macro command called
modify_locations and double-click to display an auto-generated dialog box based on the
macro. It should look like this:
2 Test the macro through this dialog box by choosing different values for the point
coordinates.
3 Revert back to the original values by closing and then redisplaying dialog box, at which
time the predefined field values will be the original default values of the macro.
(Remember that during parameter declaration in the macro, the default values were
specified as constant, as opposed to updated.)
4 Select OK to revert back to the original values.
If the students get errors like:
ERROR: invalid input. Enter an object, qualifier, or action
The command was not executed
>>20.7
it means that theyve forgotten the ! character when declaring parameters at the top of the file.
Workshop 14-Working with DiuIog oes,,,
Dialog Boxes 303
Chunging the dutubuse Iocution of the diuIog bo
First, you will determine the database location of the dialog box, then you will change it to
.my_cust.modify_locations_dbox.
To determine the Iocution:
1 Display the Database Navigator.
2 Set Filter Type to Browse.
Hint: Scroll all the way down to the bottom of the pull-down list.
The Database Types dialog box appears.
3 Select Graphic_Interface_Dialog_Box.
4 Select OK.
The Database Navigator lists all applicable objects.
5 Find the dialog box you modified.
6 What is the name of this dialog box in the database? _____________________________
As you can see, ADAMS/View automatically placed it in a library called .gui and its name
is the name of the macro that generated it.
7 Did this exist prior to double-clicking on the user-entered command in the Command
navigator for the first time? ____ Yes ____ No
To chunge the nume und Iocution of the diuIog bo to
,my_cust,modify_Iocutions_dbo:
1 From the ADAMS/View Edit menu, select Rename.
2 Select the dialog box you want to rename.
3 Enter .my_cust.modify_locations_dbox.
4 Select OK.
Workshop 14-Working with DiuIog oes,,,
304 Dialog Boxes
Working with the DiuIog o uiIder
The ADAMS/View Dialog Box Builder is a very powerful tool that facilitates customizing the
interface.
To use the DiuIog o uiIder:
1 From the Tools menu, point to Dialog Box, and then select Modify.
The Database Navigator opens.
2 Select .my_cust.modify_locations_dbox.
Both the Modify Locations and Dialog Box Builder windows appear.
The modify_locations_dbox dialog box should look like this:
3 What is displayed in the title of the Dialog Box Builder window at this time?
________________________________________________________________
Workshop 14-Working with DiuIog oes,,,
Dialog Boxes 305
4 Look at the attributes indicator. What does it say?
____________________________________________________________________
5 What are the different attribute categories for the current selected object?
______________, ______________, ______________, ______________
Attributes
Indicator
Workshop 14-Working with DiuIog oes,,,
306 Dialog Boxes
Working with uttributes
To work with uttributes:
1 Display the layout attributes of the modify_locations dialog box. What are the following
values?
s Left = __________
s Top = __________
s Width = __________
s Height = __________
2 Move the Modify Locations dialog box to the upper right corner of your screen by
clicking and dragging on the title bar.
Watch the Left and Top parameter values change as you move the dialog box around on the
desktop.
3 Resize the Modify Locations dialog box so that there is not a lot of open space for the
fields.
At this time, the modify_locations dialog box should look like this:
Workshop 14-Working with DiuIog oes,,,
Dialog Boxes 307
4 Under the layout attribute, now what are the following values?
s Left = __________
s Top = __________
s Width = __________
s Height = __________
5 Display the appearance attributes of the modify_locations dialog box and change the
following parameter values:
s Title Text: Disk Transfer Linkage Locations
s Can Be Iconified: No
s Can Be Resized: No
s Has Decorations: Yes
Once the above parameters are entered, you must select Apply for the changes to take affect.
6 Test the dialog box appearance by, from the Options menu in the Dialog Box Builder,
selecting Test Box .
The dialog box should look like this:
7 Revert back to modifying the dialog box by clearing the selection of Test Box from the
Options menu.
8 Display the command attributes of the modify_locations dialog box.
9 Display the dialog box Start commands.
Workshop 14-Working with DiuIog oes,,,
308 Dialog Boxes
10 What is the first command in this group of commands?
_____________________________________________________________________
11 What does it do? _______________________________________________________
12 What are the full keyword names and parameter names?
_____________________________________________________________________
Tip: Use the Command Navigator for assistance with this.
13 If the macro that automatically created this dialog box had a default qualifier of updated
default (U=...) instead of constant default (D=...), would these start commands exist?
____ Yes ____ No
14 Would any Start commands exist? _____ Yes _____ No
15 Display the dialog box Execution commands.
16 In the command area, right-click and point to References.
17 What are the first six reference options?
__________, __________, __________, __________, __________, __________
18 Match the reference options with the value you think they represent. One has been done
for you.
Tip: You can verify this by adding these commands to your execution commands,
selecting Apply, choosing Test Box, and then selecting Apply again:
info empty
var set var = .my_cust.temp_var string=<reference to be tested>
list ent ent = .my_cust.temp_var
var del var = .my_cust.temp_var
Reference options:
1. $_value
2. $_self
3. $_parent
4. $_topgui
5. $f_pl_x
6. $f_pl_y
VuIue:
-68.4
.my_cust.modify_locations_dbox
53.7
Error -- does not apply in this case
.my_cust
.my_cust.modify_locations_dbox
Workshop 14-Working with DiuIog oes,,,
Dialog Boxes 309
19 Display the help attributes and change the following parameter value:
Tip Text: Modify key locations of the disk transfer mechanism
Again, once the parameters are entered, be sure that you select Apply on the Dialog Box
Builder.
20 Test the appearance of the dialog box by, from the Options menu, selecting Test Box.
Notice that the tip text appears in the status bar at the bottom of the main window.
21 Revert back to modifying the dialog box by clearing Test Box.
22 From the Dialog Box menu, point to Export, and then select Command File.
A command file with the name of the dialog box, modify_locations_dbox (with a .cmd
extension), is now saved in your current working directory.
23 Rename the modify_locations_dbox.cmd to modify_locations_dbox1.cmd in your current
working directory.
Viewing informution ubout IubeIs
Here you will view information about the label.
To determine the nume of the IubeI whose uppeurunce tet is P1 X:
1 Select the label by doing one of the following:
s Single-click on the object itself.
s Browse for the object using the Database Navigator (from the Dialog Box Builder Edit
menu, select Select).
Notice the label turns blue.
2 What is currently displayed in the title of the Dialog Box Builder window?
__________________________________________________________________
3 What is displayed in the attributes indicator area? _____________________________
4 From the Dialog Box Builder Edit menu, select Attributes.
Floating tip box will only appear if cursor is not on a dialog box object (that is, in the teal-colored back-
ground area).
You dont have to check and uncheck Test Box. It will update after you select Apply.
Workshop 14-Working with DiuIog oes,,,
310 Dialog Boxes
5 Now what is displayed in the attributes indicator area? _________________________.
Note: An object can be selected in the dialog box itself (that is, its color is blue), but not
necessarily be listed in the attributes indicator area of the Dialog Box Builder.
You must ensure that the object whose attributes you are modifying is indeed
shown in this area. Ask the instructor for clarification if needed.
If you double-click on an object, note that the object itself turns purple, has
reshaping handles around it, and is shown in the attributes indicator area of the
Dialog Box Builder.
6 What are the different attribute categories for the label object?
______________, ______________, ______________, ______________
7 What is the full database name of this label object? ______________________________
You can determine or confirm this using the Database Navigator.
Modifying IubeIs
Here you will delete and rename the labels as shown below:
Rename these
Delete
these
FOR
AFTR
Workshop 14-Working with DiuIog oes,,,
Dialog Boxes 311
To modify the IubeI:
1 Delete labels whose appearance text is P1 Y, P2 Y, and P4 Y.
From the Dialog Box Builder Edit menu, point to Select, and then select Delete. This ensures
that the label is the selected object.
2 Rename the label to l_p1.
To ensure that the label is the selected object, from the Edit menu, select Rename.
3 Modify the l_p1 labels layout attribute based on the following parameter values:
s Left = leave existing value
s Top = leave existing value
s Width = 50
s Height = 25
s Fit Width = no
s Fit Height = no
s Units = Pixel
Remember to select Apply when youre finished making your changes.
4 Modify the l_p1 labels appearance attribute based on the following attributes:
s Label Text = Point 1
s Icon File = <blank>
s Justified = Left
Remember to select Apply when youre finished making your changes.
Verify the l_p1 labels resizing attribute is Attach Top and Attach Left.
5 Repeat Steps 2 through 4 above for the label whose appearance text is P2 X, with the
following differences:
s Label Name = l_p2
s Label Text = Point 2
6 Repeat Steps 2 through 4 above for the label whose appearance text is P4 X, with the
following differences:
s Label Name = l_p4
s Label Text = Point 4
Workshop 14-Working with DiuIog oes,,,
312 Dialog Boxes
7 Create a label called x_label whose appearance text is X and whose label size (width and
height) is the same as the other labels on the dialog box.
s From the Dialog Box Builder Create menu, select Label.
s Click-and-drag the area on the modify_locations_dbox dialog box where you want to
add the label.
Do not worry about the placement (left and top) of this label at this time. Ensure that
the label text is centered in the width of the label.
s Modify the appropriate attributes.
8 Repeat Step 7, creating a label called y_label and use appearance text of Y.
The modify_locations_dbox dialog box should now look like the following, with the
exception of the placement of the X and Y labels:
Suving the diuIog bo
To suve the eisting diuIog bo:
1 From the Dialog Box menu, point to Export, and then select Command File.
A command file with the name of the dialog box, modify_locations_dbox (with a .cmd
extension), is now saved in your current working directory.
2 Rename the modify_locations_dbox.cmd to modify_locations_dbox2.cmd in your current
working directory.
Workshop 14-Working with DiuIog oes,,,
Dialog Boxes 313
Working with fieIds
Now that youve had time working with dialog box objects (selecting, editing attributes,
renaming, and so on), you should be able to answer the following questions:
1 What are the names of the six fields in the dialog box?
s _______________
s _______________
s _______________
s _______________
s _______________
s _______________
2 What are the six different attributes for the field object?
3 What are the different field attribute value types?
_____________, _____________, _____________, _____________
4 Sketch the database structure of this dialog box and its contents.
______ Width
______ Layout
______ Help
______ Commands
______ ICON_File
______ Height
______ Appearance
______ Value
______ Resizing
______ OFF
Workshop 14-Working with DiuIog oes,,,
314 Dialog Boxes
To chunge fieId sizes:
1 Using the Dialog Box Builder, and the procedures described earlier, modify the f_p1_x
field width to 50 pixels.
2 Modify all remaining field widths by doing the following:
s Select the fields by clicking and dragging from point A to point B (on the figure
shown below).
Notice that as the fields are selected, they turn blue.
s In the Dialog Box Builder, select the Align Width tool to set the remaining
widths to that of the first field.
In Test Box mode, the modify_locations_dbox dialog box should now look like the
following, with the exception of the placement of the X and Y labels:
A
B
Workshop 14-Working with DiuIog oes,,,
Dialog Boxes 315
Moving diuIog bo obgects
To move diuIog bo obgects:
1 Move the objects around in the dialog box so that it looks like the following:
Because you will not need to resize any of the objects, the only buttons you would need to
use on the Dialog Box Builder toolbar are the following:
To select multiple objects on the dialog box, simply click and drag your mouse across the
objects you want to include, starting from the background of the dialog box.
2 Save the existing dialog box:
Workshop 14-Working with DiuIog oes,,,
316 Dialog Boxes
porting u diuIog bo
To eport u diuIog bo:
1 From the Dialog Box menu, point to Export, and then select Command File.
A command file with the name of the dialog box, modify_locations_dbox (with a .cmd
extension), is now saved in your current working directory.
2 Rename the modify_locations_dbox.cmd to modify_locations_dbox3.cmd in your current
working directory.
ModuIe review
1 What are the top-level libraries that are supplied with the standard ADAMS/View
database (not including models)?
________________________________________________________________________
2 What is the difference between single-clicking and double-clicking on a dialog box object
when modifying a dialog box?
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
3 Would an auto-generated dialog box get updated if the macro that generated it was
modified with a new parameter?
________________________________________________________________________
________________________________________________________________________
4 Can you slam, or move, multiple objects in a dialog box by using the move icons on the
Dialog Box Builder?
________________________________________________________________________
________________________________________________________________________
Workshop 14-Working with DiuIog oes,,,
317
JS
DIALO9 OX UILDR
Create a custom interface that modifies the x and y coordinate locations of points
1, 2, and 4 of the disk transfer linkage, simulates the new design, and allows easy
review of results.
Whut's in this moduIe:
s Substituting Text into Commands, 318
s Working with Dialog Box Objects, 320
s Saving Dialog Boxes, 326
s Workshop 15Working with the Dialog Box
Builder, 327
318 Dialog Box Builder
Substituting Tet into Communds
Holding down the right mouse button over the Commands area of the Dialog Box Builder
displays a pop-up menu with several options for editing the commands. When you select
References, you can display and insert the available $xxx references.
Identifier: Substitutes the:
$_value Current value of the object that contains the command.
$_self Full database name of the object executing the com-
mand.
$_parent Full database name of the objects immediate parent.
$_topgui Full database name of the parent dialog box.
$object_name Current value of the object being referenced.
Dialog Box Builder 319
Substituting Tet into Communds,,,
Obgects thut contuin vuIues
umpIe
The object: Has the value:
Field Contents of field.
Option_menu Value for current selection.
Radio_box Value for current selection.
Toggle button Specified on/off value.
Slider Integer slider value.
Identifier: Substitutes the following text:
$_value 20.7
$_self .my_cust.design_layout.cont_P2.field_y
$_parent .my_cust.design_layout.cont_P2
$_topgui .my_cust.design_layout
$field_x -66.2
.my_cust.design_layout.cont_p2.field_y
library dialog box container field
320 Dialog Box Builder
Working with DiuIog o Obgects
uttons
Rudio boes
SIiders
Contuiners
Option menu
Dialog Box Builder 321
Working with DiuIog o Obgects,,,
uttons
s Buttons do not contain values. They simply execute commands upon single- or
double-click.
Rudio boes
SIiders
Contuiners
Option menu
Button
Buttons
322 Dialog Box Builder
Working with DiuIog o Obgects,,,
uttons
Rudio boes
Set states or modes.
SIiders
Contuiners
Option Menu
Radio boxes
Text appearance
Values
Dialog Box Builder 323
Working with DiuIog o Obgects,,,
uttons
Rudio boes
SIiders
s Sets value of an object without having to type it in.
s Currently limited to integer values.
Contuiners
Option menu
As you move the slider to
the right, notice that the
value changes.
324 Dialog Box Builder
Working with DiuIog o Obgects,,,
uttons
Rudio boes
SIiders
Contuiners
s Sub-region inside dialog box, window, or toolbar.
s Can hold other objects.
Option menu
Container for the
Link tool
Container for
Design Study
Dialog Box Builder 325
Working with DiuIog o Obgects,,,
uttons
Rudio boes
SIiders
Contuiners
Option menu
s Allows one of many selections
s Contains a push graphic that displays the entire list, like a menu.
s Displays only one column of options.
When you pull down the arrow
here...
you get the menu of available
selections here.
326 Dialog Box Builder
Suving DiuIog oes
s On the Dialog Box menu, point to Export, and then select Command File.
x The dialog box is saved in the current working directory.
x The file name will be the dialog box name.
x You probably want to rename the file so that subsequent saves do not
overwrite the file.
s You can also save your dialog box by saving your modeling database as a binary file.
All of your changes are saved if you save a binary file.
Dialog Box Builder 327
This workshop takes about one hour to complete.
ProbIem stutement
Create a custom interface that modifies the x and y coordinate locations of points 1, 2, and 4 of
the disk transfer linkage, simulates the new design, and allows easy review of results.
9etting sturted
To import the modeI:
1 Start ADAMS/View from the mod_15_dboxes_II directory.
2 Import the model, disk_start_3.cmd.
Remind them to look at the tips found throught the workshop documentation. It may save them some time.
As an example, show them the tip on page 331.
XII I
II
III
IV
V VI VII
X
XI
VIII
IX
Workshop 1-Working with the DiuIog o uiIder
328 Dialog Box Builder
Creuting u Iibrury
Here, you will create a library as a database storage area for easy access to all of your
customization objects.
To creute u Iibrury:
1 Display the Command Navigator.
2 Select library, and then select create to open the Library Create dialog box.
3 Create a library called .my_cust
Creuting the design Iuyout diuIog bo
You must first create a baseline dialog box that modifies the design layout of the disk transfer
mechanism. Once created, you will work on the objects that will be placed on them.
To creute the design Iuyout diuIog bo:
1 From the Tools menu, point to Dialog Box, and then select Create.
This opens the Dialog Box Builder.
2 Create a dialog box called .my_cust.design_layout:
s From the Dialog Box menu, select New to display the New Dialog Box dialog box.
s In the Library text box enter my_cust.
Note: Do not include the period (.) in the Library text box. This dialog box assumes that
all libraries created will be at the root level. Including the period will put the
dialog box in the .gui directory (currently a known issue with ADAMS/View).
s In the Name text box enter design_layout.
s Select Close.
s Select OK.
3 Modify the .my_cust.design_layout dialog box as follows:
s Attributes - Layout: 335 pixels (width) by 181 pixels (height)
Do not worry about placement at this time.
Workshop 1-Working with the DiuIog o uiIder,,,
Dialog Box Builder 329
Adding buttons
You are now going to add buttons so that selecting them will modify the x and y coordinates of
Point 1 of the disk transfer mechanism in increments of 2 millimeters. Here you will create a
button that subtracts 2mm from the existing x coordinate value of point 1, controlled through
the design variable DV_p1_x.
To udd buttons:
1 In the Dialog Box Builder, from the Create menu, select Button.
2 Click and drag the area on the design_layout dialog box where you would like to add the
label.
3 Use the following parameter values for the button:
s Name:
x .my_cust.button_x_neg
s Attributes - Layout:
x 25 pixels (width) by 25 pixels (length)
Do not worry about placement at this time.
s Attributes - Appearance:
x -
s Attributes - Commands:
x Enter the following to modify the design variable by subtracting 2 mm from its current
value:
variable modify &
variable_name=.model_1.DV_P1_X &
real_value=(eval(DV_P1_X-2))
Button you
will add
Workshop 1-Working with the DiuIog o uiIder,,,
330 Dialog Box Builder
Testing the button
Test the button to verify that clicking on it will indeed modify the current x coordinate of point
1 by -2 millimeters.
To test the button:
1 In the Dialog Box Builder, from the Options menu, select Test Box.
2 When done testing, revert back to modifying the dialog box by selecting Test Box again.
Creuting udditionuI buttons
Create additional buttons that will control the x and y locations of point 1 in increments of
positive and negative 2 mm, as well as one to reset to default values, as shown below.
To creute udditionuI buttons:
3 Use the following parameter values for these buttons:
s Names:
x .my_cust.button_x_pos
x .my_cust.button_y_neg
x .my_cust.button_y_pos
x .my_cust.button_reset
s Attributes - Layout:
x 25 pixels (width) by 25 pixels (length) for all
Do not worry about placement at this time.
Workshop 1-Working with the DiuIog o uiIder,,,
Dialog Box Builder 331
s Attributes - Appearance:
x + (for .my_cust.button_x_pos and .my_cust.button_y_pos)
x - (for .my_cust.button_y_neg)
x R (for .my_cust.button_reset)
s Attributes - Commands:
x variable modify variable_name= real_value=
Note: The following default values are used to reset the design variables:
Tip: You may want to use the copy and paste feature of the Dialog Box Builder to make
creating these other button objects easier. To do this, first select the button you want
to copy by single clicking on it. Next, in the Dialog Box Builder, from the Edit
menu, select Copy immediately followed by Paste for each additional button.
Use the dialog box toolbar icons to move the button into the clean, neat configuration as
shown in the figure on page page 330.
4 Test the button to verify that selecting on the buttons do indeed modify the x and y
coordinates of point 1 properly:
s In the Dialog Box Builder, from the Options menu, select Test Box.
s When done testing, revert back to modifying the dialog box by selecting Test Box
again.
.model_1.DV_P1_X -68.4
.model_1.DV_P1_Y 53.7
Workshop 1-Working with the DiuIog o uiIder,,,
332 Dialog Box Builder
Adding fieIds
In this section you will add fields that only display the x and y coordinates of point 1. Therefore,
as you are selecting the up and down buttons to move point 1 in increments of 2 mm, you can
immediately see what the coordinate values are in the same dialog box. These fields will,
therefore be non-editable.
To udd fieIds:
1 Add fields and labels using the following parameter values:
x Names:
x .my_cust.design_layout.field_x
x .my_cust.design_layout.field_y
Accept the default names for the 2 labels.
x Attributes - Layout:
x 75 pixels (width) by 25 pixels (length) for all
Do not worry about placement at this time.
x Attributes - Value:
x Field Type = Real
x Preload String = -68.4 for field_x and 53.7 for field_y
x Editable = No
2 Use the toolbar on the Dialog Box Builder to move the fields into the configuration
shown in the figure above.
Fields and
labels to
be added
Workshop 1-Working with the DiuIog o uiIder,,,
Dialog Box Builder 333
3 Add commands to the buttons so that they update the field values.
s Commands to be added to all buttons:
interface field set field_name=$_parent.field_x database=".model_1.DV_P1_X"
interface field set field_name=$_parent.field_y database=".model_1.DV_P1_Y"
4 Test the buttons to verify that they do indeed modify the x and y coordinates of point 1
and update the fields properly.
Adding u rudio bo und contuiner
In this section, you will add the capability to control both points 1 and point 2. You will use a
radio box to choose the point you want to control, at which time it will display the appropriate
container.
To udd u rudio bo:
1 In the Dialog Box Builder, from the Create menu, select Radio Box.
2 Click and drag the area on the design_layout dialog box where you would like to add the
radio box. (This should be roughly across the top of the dialog box.)
Workshop 1-Working with the DiuIog o uiIder,,,
334 Dialog Box Builder
3 Use the following parameter values for the radio box:
s Name: .my_cust.design_layout.radio_points
s Attributes - Layout: 30 pixel height
s Attributes - Value:
Point 1 | 1
Point 2 | 2
Every line entry means there will be another option to choose from on the radio box.
The text to the left of the pipe (the |) will be the text displayed next to the button, while
the value to the right is the value returned by the radio box for that selection while the
dialog box is in use.
4 Modify the appearance of the radio box so that it located at the top of the dialog box and
spans the entire width of the dialog box.
Select the radio box, and then select the following icons on the Dialog Box Builder toolbar
in the order indicated:
1
2
3
Workshop 1-Working with the DiuIog o uiIder,,,
Dialog Box Builder 335
To creute u contuiner:
1 From the Create menu, select Container.
2 Click and drag the area on the design_layouts dialog box where you would like to add the
container.
This should be in the middle of the dialog box, on top of all custom fields and buttons of
the dialog box, as shown below:
3 Use the following parameter values for this container:
s Name:
x .my_cust.design_layout.cont_p1
4 Modify the appearance of the container so that it spans the entire length and width of the
middle area of the dialog box.
Select the container, and then click on the last four icons on the Dialog Box Builder toolbar
to expand the container left, right, down, and up.
The dialog box should now look similar to the following:
Workshop 1-Working with the DiuIog o uiIder,,,
336 Dialog Box Builder
Moving buttons und fieIds onto the contuiner
In this section you will add the capability to control both points 1 and 2. You will move the
buttons and fields (except for the Close button) so that they belong to the container, instead of
being direct children objects of the dialog box.
The quickest way to do this is by cutting the objects onto the clipboard, and then pasting them
onto the container. To select the objects necessary for the cutting, you must first undisplay the
container that is currently on top of them.
To undispIuy the contuiner:
1 Select it in the design_layout dialog box.
2 In the Dialog Box Builder, from the Edit menu, select Undisplay.
Note that undisplaying a dialog box object does not delete or modify it. All it does is
undisplay it from the dialog box to which it belongs.
To copy und cut the buttons:
1 Select the buttons and fields you want to cut.
Do this by clicking and dragging on the dialog box to make a rectangular area that either
touch or surround all objects, as shown in the following:
Notice that all of the fields change colors to indicate that they are selected, except for
buttons (currently a known issue in ADAMS/View).
2 In the Dialog Box Builder, from the Edit menu, select Cut to place all objects onto the
ADAMS/View clipboard.
Click and drag
here
Workshop 1-Working with the DiuIog o uiIder,,,
Dialog Box Builder 337
3 Open the container called .my_cust.design_layout.cont_p1:
s From the Dialog Box menu, point to Open, and then select Container.
s Browse for the object in the Database Navigator.
Notice the container is now once again visible and also selected.
4 What is in the title of the Dialog Box Builder at this time? _________________________
5 What is in the attributes area of the Dialog Box Builder at this time? ________________
6 Ensuring that the container is open (based on the Dialog Box Builder title), from the Edit
menu, select Paste to paste the objects previously placed on the ADAMS/View clipboard
onto the container.
Notice that they are all placed onto the container and are still selected.
7 Move this selected group of objects into the center of the container by clicking and
dragging on one of the selected objects.
8 Can you move objects that belong to a container outside of the boundary of that
container? ______ Yes ______ No
The dialog box should look like the following:
Workshop 1-Working with the DiuIog o uiIder,,,
338 Dialog Box Builder
tending diuIog bo cupubiIity to controI point Z
In this section, you will copy the container and its buttons and fields that control point 1 so that
you can extend this capability to point 2.
To etend the diuIog bo to controI point Z:
1 Open the dialog box and select the container.
2 Copy and paste the container to create a duplicate one.
3 Name this container .my_cust.design_layout.cont_p2.
4 Slam the new container down against the Close button by clicking the down arrow on the
Dialog Box Builder toolbar.
The new container should have the same placement as the original one.
5 Modify the objects on the new container to control the x and y coordinate locations of
point 2 instead of point 1.
The default x and y values for point 2 are (-66.2, 20.7).
Tip: To work with objects that belong to a container, you must first open the container by
selecting the Dialog Box menu, point to Open, and then select Container.
Be sure to test this new functionality before moving on to the next section.
Workshop 1-Working with the DiuIog o uiIder,,,
Dialog Box Builder 339
Adding progrumming to the rudio bo
Here you will add programming to the radio box to display the appropriate container.
To udd progrumming:
1 Add the following commands to the radio box:
if cond=( $radio_points == 1 )
interface container undisplay container=$_parent.cont_p2
interface container display container=$_parent.cont_p1
elseif cond=( $radio_points == 2 )
interface container undisplay container=$_parent.cont_p1
interface container display container=$_parent.cont_p2
These commands simply ensure that the appropriate container is displayed based on the
current radio button choice.
Be sure to test this new functionality before moving on to the next step.
2 Save the existing dialog box:
s From the Dialog Box menu, point to Export, and then select Command File.
A command file with the name of the dialog box, design_layout (with a .cmd extension),
is now saved in your current working directory.
Workshop 1-Working with the DiuIog o uiIder,,,
340 Dialog Box Builder
Creuting u diuIog bo to simuIute the system
In this section, you will create a simple dialog box that simulates the system to 1 second with
50 output steps, with the choice of the model display updating at every output step, at simulation
end, or never.
To creute u diuIog bo to simuIute the system:
1 Create a dialog box called .my_cust.Simulate.
s The only buttons that should exist on this dialog box when initially created are Apply
and Close.
s The size of the dialog box should be 335 pixels (width) by 178 pixels (height).
s Do not worry about placement at this time.
2 Add the following objects to the dialog box:
You should now be comfortable working with general Dialog Box Builder functions, as
well as label, field, and button objects.
The options menu attributes value should be the following:
At Every Output Step | output_step
At Simulation End | end
Never | none
The dialog box execute commands should be the following:
simulation single_run set update= <option menu value>
simulation single scripted &
sim_script_name = .model_1.disk_script &
reset_before_and_after = yes
The option menu value is only executed when they click Apply. If they want the Model Display Update
to be modified immediately, they need to use commands. Show them the command that was used in
Workshop 1Introduction on page 17, or in the Settings dialog box.
Label
Label
Option
menu
Workshop 1-Working with the DiuIog o uiIder,,,
Dialog Box Builder 341
3 Save the existing dialog box by exporting the command file.
A command file with the name of the dialog box, Simulate (with a .cmd extension), is now
saved in your current working directory.
Creuting u diuIog bo to review the system
In this section, you will create a dialog box that allows others to review the results. The results
are presented in two ways:
s Animation with point-traces, allowing you to visually inspect the motion.
s Drop angle computed from the last design simulated.
To creute u diuIog bo to review the system:
1 Create a dialog box called .my_cust.review.
s The only button that should exist on this dialog box when initially created is the
Close button.
s The size of the dialog box should be 335 pixels (width) by 90 pixels (height).
s Do not worry about placement at this time.
2 Add the following objects to the dialog box:
The Animate button commands should be the following:
graphic_results animate &
point_trace_marker = .model_1.DISK_1.MARKER_lower, &
.model_1.DISK_1.MARKER_upper
The Actual Angle button commands should be the following:
variable set variable_name=.model_1.actual_angle &
real=(eval(MIN(.model_1.Last_Run.ANGLE_MEA_DROP_ERROR.Q)+desired_angle))
info empty
list entity entity=.model_1.actual_angle
3 Save the existing dialog box by exporting the command file.
A command file with the name of the dialog box, review (with a .cmd extension), is now
saved in your current working directory.
Button
Button
Workshop 1-Working with the DiuIog o uiIder,,,
342 Dialog Box Builder
ModuIe review
1 What are the valid parameters types that can be returned based on a selection in radio
boxes and options menus?
________________________________________________________________
2 What would the following return in the commands section of the Dialog Box Builder for
the customization work performed in this workshop?
Open: .my_cust.design_layout dialog box
Edit object: .my_cust.design_layout dialog box
$_value _______________________________
$_self _______________________________
$_parent _______________________________
$_topgui _______________________________
Open: .my_cust.design_layout.cont_p1 container
Edit object: .my_cust.design_layout.cont_p1.field_x
$_value _______________________________
$_self _______________________________
$_parent _______________________________
$_topgui _______________________________
Workshop 1-Working with the DiuIog o uiIder,,,
343
J6
WRAP-UP
Package the files that build the new interface so that they are organized and
upwardly compatible.
Whut's in this moduIe:
s Build Files, 344
s Workshop 16Wrap-up, 345
344 Wrap-up
uiId FiIes-
s Files that read in (or create) the various components of a customized interface are
typically called build files.
s It is highly recommended that you organize all types of GUI customization objects in
subdirectories for organization and easy access.
s Sample build file:
Tell the students that vertical applications use different naming conventions and build procedures. Refer
them to the guide, Customizing ADAMS/Car.
Wrap-up 345
This workshop takes about one hour to complete.
ProbIem stutement
Package the files that build the new interface so that they are organized and upwardly
compatible.
XII I
II
III
IV
V VI VII
X
XI
VIII
IX
Workshop 1-Wrup-up
346 Wrap-up
Orgunizing the fiIe system structure
In this section, you will organize your file system structure such that all files necessary to build
the custom interface are easily accessible.
To orgunize the fiIe system structure:
1 From the mod_16_disk directory, create the following directories:
s dboxes
s menus
s model
See the instructor if you need help with this.
2 Copy files from Workshop 15Working with the Dialog Box Builder on page 327 to the
new directory structure.
Ensure that the command files representing the three dialog boxes (design_layout,
Simulate, and review) are placed in the new dboxes directory, and that the command file
representing the model is placed in the new model directory.
3 Rename the model file from disk_start_3.cmd to disk_final.cmd.
For now, the menus directory will be empty.
Workshop 1-Wrup-up,,,
Wrap-up 347
Creuting u buiId fiIe
You will now create a build text file that essentially builds the custom interface and reads in the
model. Remember that the dialog boxes were stored and saved in a user-created library. If the
library does not exist, reading in the command files that build the dialog boxes will not work.
To creute u buiId fiIe:
1 Create a text file called build.cmd in the mod_16_disk directory that builds the
ADAMS/View interface to contain the model and the three dialog boxes.
!--- Read in the command file
file command read file=
!--- Create the library
library create library_name=
!--- Import the dialog boxes
file command read file=
2 Start ADAMS/View from the mod_16_disk directory.
3 Import the file called build.cmd from the mod_16_disk directory to build the custom
interface.
If errors are generated, debug the build command file until you no longer get errors when
reading this file into a fresh session of ADAMS/View.
4 Update the build command file so that it also displays the dialog boxes.
You should be able to do this on your own. If you need help with the command syntax,
display one of the dialog boxes. (From the Tools menu, point to Dialog Box, select Display,
and then review the command used behind the scenes by displaying the ADAMS/View
Command Window.)
5 Test the new build file from a fresh ADAMS/View session.
Workshop 1-Wrup-up,,,
348 Wrap-up
Creuting menus
In this section, you will create a command file that builds menus to easily display the custom
dialog boxes.
To creute menus:
1 Create a command file called disk_menus.cmd in the mod_16_disk/menus directory that
creates menus to display the dialog boxes.
!--- Create custom menus for the disk transfer mechanism
interface menu create &
menu_name = &
label =
interface push create &
push_button_name = &
label = &
command =(use the command to display a dialog box)
2 Update the build command file so that it reads in this command file that will build menus.
Because you will now have custom menus that will display these dialog boxes, you can
comment out or delete the commands that display the custom dialog boxes.
3 Test the new build file from a fresh ADAMS/View session.
Workshop 1-Wrup-up,,,
Wrap-up 349
Swupping u diuIog bo
In this section, you will learn how to swap one dialog box for another one using a build
command file.
To swup u diuIog bo:
1 Copy the design_layout dialog box command file that was used in Workshop 1
Introduction (module_01_intro/dboxes/design_layout_dbox.cmd) to the module_16_disk/
dboxes directory.
2 Rename this file to design_layout_advanced.cmd.
This dialog box is slightly more advanced because it allows the user to also control point
4, instead of just points 1 and 2.
3 Update the build file so that it replaces the existing design_layout dialog box with the new
one.
You have now learned how to put together a custom interface containing models, dialog boxes,
menus, libraries, and potentially macros into a clean and organized structure. This method will
also ensure that your customization work is upwardly compatible with future versions of
ADAMS/View.
Workshop 1-Wrup-up,,,
350 Wrap-up
ModuIe review
1 If dialog boxes were created in the .gui library and the session was saved in binary file
format in ADAMS/View version 10.1, would they exist in version 11.0?
____________________________________________________________________
What if they were created in a user-created library?
____________________________________________________________________
2 If your custom interface included a macro stored in a subdirectory called macros, what
build file command(s) would you use to read in the macro?
____________________________________________________________________
____________________________________________________________________
Workshop 1-Wrup-up,,,
351
A
MACRO
This appendix contains the sample macro that is provided with this training
course.
Whut's in this uppendi:
s Macro for Workshop 14, 352
352 Macro
Mucro for Workshop 14
Mucro for Step 2 on puge 300
! This macro modifies the x and y locations of Points 1, 2, and 4 in the disk transfer
mechanism.
!$P1_X: t=real: D=-68.4: C=1
!$P1_Y: t=real: D=53.7: C=1
!$P2_X: t=real: D=-66.2: C=1
!$P2_Y: t=real: D=20.7: C=1
!$P4_X: t=real: D=-47.9: C=1
!$P4_Y: t=real: D=9.3: C=1
variable modify variable_name=.model_1.DV_P1_X real_value=$P1_X
variable modify variable_name=.model_1.DV_P1_Y real_value=$P1_Y
variable modify variable_name=.model_1.DV_P2_X real_value=$P2_X
variable modify variable_name=.model_1.DV_P2_Y real_value=$P2_Y
variable modify variable_name=.model_1.DV_P4_X real_value=$P4_X
variable modify variable_name=.model_1.DV_P4_Y real_value=$P4_Y
353
B
AMSWR KY
Whut's in this uppendi:
s Answer Key for Workshop 1, 354
s Answer Key for Workshop 2, 355
s Answer Key for Workshop 3, 356
s Answer Key for Workshop 4, 357
s Answer Key for Workshop 5, 358
s Answer Key for Workshop 6, 359
s Answer Key for Workshop 7, 360
s Answer Key for Workshop 8, 361
s Answer Key for Workshop 9, 362
s Answer Key for Workshop 10, 363
s Answer Key for Workshop 11, 364
s Answer Key for Workshop 13, 365
s Answer Key for Workshop 14, 366
s Answer Key for Workshop 15, 368
s Answer Key for Workshop 16, 369
354 Answer Key
Answer Key for Workshop 1
Step 2, page 21: 6.797
Step 2, page 21: No
Step 2, page 22: DV_p4_x (+2.99%)
Step 3, page 22: DV_p2_y (+0.293%)
Step 4, page 22:
Step 7, page 22: Yes
Step 3, page 23:
X Y
Point 1 -66.6071 53.0906
Point 2 -65.213 20.7607
Point 4 -49.3324 9.25845
-1 mm (degrees)
Nominal
(degrees)
+1 mm
(degrees)
DV_p4_x -3.034 0 2.8393
DV_p2_y .95208 0 -1.0869
Answer Key 355
Answer Key for Workshop Z
Quiz:, page 38:1=Integer, 2=Object, 3=String, 4=String, 5=Real, 6=Object, 7=Matrix (Array of
reals)
Step 1, page 47: .express_test.steel - database object
Step 2, page 47: This variable is only referenced by the left wing, not the right; data type is
character string.
Step 3, page 47: .express_test.rt_pillar.MARKER_22 - database object
Step 4, page 47: 300.0, -100.0, 203.0 - array of real numbers
Step 5, page 47: 6.83 - real value
Step 6, page 47: jt_rt_pillar - character string
Step 7, page 47: 7-integer number
356 Answer Key
Answer Key for Workshop 3
Step 2, page 59: .cyl_mod.PART.MARKER_1
Step 1, page 67: By default the center of mass (CM) location for a part is derived from the
geometry and material type. A change in cylinder length automatically results in ADAMS/View
updating the CM location. Therefore, parameterizing the CM location yourself would be in
conflict with what ADAMS/View is trying to do. If you want to parameterize a CM location you
must define the mass and inertia using User Input instead.
Step 2, page 67: No, it cannot. You can only use design-time functions to define the model
configuration. The only geometry types that change shape during run-time are outline, spring-
damper, and force graphics.
Step 3, page 67: Yes, the cylinder length can be dependent on the design-time STEP function.
This would allow you to control the length based on conditional logic. This might be something
youd want to do in a design study, DOE, or optimization. If you have internet access, see KB
Article 8464 for an example.
Answer Key 357
Answer Key for Workshop 4
Step 2, page 77:
Step 1, page 78: .sla.tierod.tierod_geo_base
Step 5, page 79: (LOC_RELATIVE_TO({0,0,0},.sla.ground.pnt7_ref))
Step 3, page 79: (ORI_ALONG_AXIS(.sla.ground.pnt7_ref, .sla.ground.pnt8_ref, z))
Step 5, page 79: No
Step 3, page 80: Yes
Step 3, page 82: 3
Step 5, page 84: No
Step 6, page 84: The center_marker location parametrics were incorrectly defined for the short
cylinders. This occurred during the attach-near operation in Step 1 on page 81. You need to
locate the center_marker along the line-of-sight from pnt3_ref to pnt4_ref.
Step 3, page 87: The markers for the spherical joint were parameterized to the design point.
Step 4, page 87: No
Step 5, page 87: A warning message would be issued saying that you were breaking a
parametric relationship.
pnt5_ref
pnt7_ref
pnt2_ref
pnt1_ref
pnt4_ref
pnt3_ref
pnt11_ref
pnt10_ref
pnt6_ref
pnt9_ref
pnt8_ref
UCA
LCA
TIEROD
SPINDLE
GROUND
358 Answer Key
Answer Key for Workshop
Step 4, page 102: Yes
Step 3, page 103: No
Step 3, page 104: No
Answer Key 359
Answer Key for Workshop
Step 3, page 126: 4
Step 4, page 126: 3
Step 5, page 126: No
Step 4, page 128: Yes
Step 6, page 129: Trial 1 and perhaps trial 2
Step 7, page 130: -25
Step 4, page 130: Yes
Step 5, page 130: Yes, the range of A1 seems well-bounded when all other variables are held
fixed. However, its possible that using other combinations of design variables may result in
unexpected motion or unforeseen linkage configurations.
Step 6, page 130: Trials 1,2
Step 1, page 131: New analyses will be created: Run_006 through Run_010 and
Multi_Run_002.
Step 2, page 131: Yes. Analyses can be deleted using the Delete Simulation Results tool or by
selecting the Tools menu, pointing to Command Navigator, pointing Analysis, and then
selecting Delete.
Step 3, page 131: Yes
Step 4, page 132: Yes, the list of values was used. Yes, it ignored the list of values.
Step 5, page 132: No, you cannot study more than one measure at a time. Yes, you can study
more than one objective at a time.
360 Answer Key
Answer Key for Workshop 7
Step 8, page 141: No, it hops in place.
Step 2, page 143: pt4_z, w1
Step 5, page 143: Trial #5, value=150
Step 3, page 144: Straight line, 45
o
left of path to zone.
Step 5, page 145: 15
Step 6, page 145: 0.333, 0.272
Step 6, page 146: 5
Step 7, page 146: 100.0, -316.51
Step 12, page 147: Right-hooking arc towards zone.
Step 13, page 147: Nearly, if not completely.
Step 14, page 147: Yes
Answer Key 361
Answer Key for Workshop
Step 8, page 162: A and B, because theyre greater than zero.
Step 6, page 164: $11.86, 55 - 6.4E-2 = 54.94
o
Step 7, page 164: No. 65 calls.
Step 9, page 164: Variable L1 was driven to its lower limit.
Step 4, page 165: Yes
Step 5, page 165: $11.60
Step 5, page 166: $11.29, 55 - 4.3E-3 = 54.996 55
o
Step 6, page 166: Yes, cost savings were gained by loosening the tolerance on hood angle.
362 Answer Key
Answer Key for Workshop 9
Step 4, page 175: model verify
Step 6, page 175: Yes
Step 5, page 176: info empty
Step 10, page 181: No
Step 11, page 181: Write the command file more generically so that its not model-name
dependent.
Step 3, page 183: Link, Cylinder, Extrusion, Ellipsoid
Step 6, page 184: CsgSolid (and/or plate)
Step 4, page 184: Yes
Step 3, page 185: Yes
Step 3, page 186: Yes
Answer Key 363
Answer Key for Workshop 10
Step 5, page 197: Yes
Step 7, page 197: No
Step 8, page 197: The commands are being executed properly, but the screen isnt being
updated.
Step 3, page 200: Yes
Step 3, page 201: Yes
Step 5, page 203: Yes
Step 6, page 203: Yes
Step 3, page 206: 0
364 Answer Key
Answer Key for Workshop 11
Step 4, page 228: All of the above.
Step 3, page 228: No, probably not.
Step 5, page 228: Yes
Step 6, page 229: Yes. Recording the new one didnt overwrite the one you renamed to
.my_zoomed_view. You may have more than one macro in the database at a time; each must
have a unique name.
Step 7, page 229: F, T, T
Step 2, page 230: C (.MACRO_1)
Answer Key 365
Answer Key for Workshop 13
Step 3, page 273: No
Quiz:, page 274: 1-Reload, 2-Export, 3-Import, 4-Apply, 5-Exits, 6-Load.
Step 2, page 275: variable sweep
Step 5, page 276: Choice #3
Step 5, page 278: F, T, F, T, T
Step 8, page 281: interface menubar read menubar=.my_cust.arc_toolkit.mbar
file="arc_toolkit.mnu
Step 7, page 283: Yes
366 Answer Key
Answer Key for Workshop 14
Step 6, page 303: .gui.modify_locations
Step 7, page 303: No
Step 3, page 304: Dialog-Box Builder: Modifying modify_locations_dbox
Step 4, page 305: Dialog Box modify_locations_dbox
Step 5, page 305: Layout, Appearance, Commands, Help
Step 1, page 306: Left=738, Top=22, Width=404, Height=203
Step 4, page 307: Left=1093, Top=50, Width=275, Height=203
Step 10, page 308: int fie set fie=$_self.f_p1_x str=-68.4
Step 11, page 308: It always sets the field values to the constant default value of 68.4. This is
the value specified for the p1_x parameter in the macro that auto generated the dialog box.
Step 12, page 308: interface field set Field_name= Strings= Action= Execute=
Step 13, page 308: No
Step 14, page 308: No
Step 17, page 308: $_value, $_self, $_parent, $_topgui, $f_pl_x, $f_pl_y
Step 18, page 308: $_value=error, $_self=.my_cust.modify_locations_dbox,
$_parent=.my_cust, $_topgui=.my_cust.modify_locations_dbox, $f_pl_x=-68.4, $f_pl_y=53.7
Step 2, page 309: Dialog-Box Builder: Modifying modify_location_dbox
Step 3, page 309: Dialog Box modify_locations_dbox
Step 5, page 310: Label l_p1_x
Step 6, page 310: Layout, Appearance, Resizing, Help
Step 7, page 310: .my_cust.modify_locations_dbox.l_p1_x
Step 1, page 313: f_p1_x, f_p1_y, f_p2_x, f_p2_y, f_p4_x, f_p4_y
Step 2, page 313: Layout, Appearance, Resizing, Value, Commands, Help
Step 3, page 313: String, Object, Numeric, File
Answer Key 367
Answer Key for Workshop 14,,,
Step 4, page 313:
Step 1, page 316: .gui, .colors, .icons, .MDI, .materials, .plot_1
Step 2, page 316: Single-clicking simply selects an object. To rename it, reshape it, or change
its attributes, you would have to click Edit => Rename/Reshape/Attributes in the Dialog Box
Builder. Double-clicking not only selects the object, but also puts it directly in the mode where
you can reshape the object or change its attributes without clicking the Edit menu.
Step 3, page 316: No. Every time a macro was modified that would change the appearance of
the auto generated macro, the dialog box needs to be deleted and recreated by clicking on the
user-entered command in the Command Navigator.
Step 4, page 316: Yes
.my_cust
.modify_locations_dbox
l_p1
l_p2
l_p4
f_p4_x
f_p4_y
f_pl_x
f_pl_y
f_p2_x
f_p2_y
x_label
y_label
OK
Apply
Cancel
368 Answer Key
Answer Key for Workshop 1
Step 4, page 337: Dialog-Box Builder: Modifying cont_p1
Step 5, page 337: Container cont_p1
Step 8, page 337: No
Step 1, page 342: real, integer, string
Step 2, page 342: First scenario: $_value=none, $_self=.my_cust.design_layout,
$_parent=.my_cust, $_topgui=.my_cust.design_layout. Second scenario: $_value=-68.4 (by
default, but will vary), $_self=.my_cust.design_layout.cont_p1.field_x,
$_parent=.my_cust.design_layout.cont_p1, $_topgui=.my_cust.design_layout
Answer Key 369
Answer Key for Workshop 1
Step 1, page 350: No; yes.
Step 2, page 350: Macro read macro_name= file_name= user_entered_command=
370 Answer Key
Motes

You might also like