Automating Tasks Using Adams - View Scripting, Macros, and GUI Customization
Automating Tasks Using Adams - View Scripting, Macros, and GUI Customization
February 2013
MSC.Software Corporation reserves the right to make changes in specifications and other information contained in this
document without prior notice. The concepts, methods, and examples presented in this text are for illustrative and
educational purposes only, and are not intended to be exhaustive or to apply to any particular engineering problem or
design. MSC.Software Corporation assumes no liability or responsibility to any person or company for direct or indirect
damages resulting from the use of any information contained herein.
Copyright © 2013 MSC.Software Corporation. All Rights Reserved. This notice shall be marked on any reproduction of
this documentation, in whole or in part. Any reproduction or distribution of this document, in whole or in part, without the
prior written consent of MSC.Software Corporation is prohibited.
The MSC.Software corporate logo, Adams, Dytran, Easy5, Fatigue, Laminate Modeler, Marc, Mentat, MD Nastran, MD
Patran, MSC, MSC Nastran, Mvision, Patran, SimDesigner, SimEnterprise, SimManager, SimXpert and Sofy are
trademarks or registered trademarks of the MSC.Software Corporation in the United States and/or other
countries. NASTRAN is a registered trademark of NASA. All other trademarks belong to their respective owners.
CONTENTS
Section Page
1 Command Language
What is in this Section 1-3
General Structure 1-4
Getting Familiar with Commands 1-7
Command Navigator 1-8
Command Window 1-10
Log File 1-12
Types of Commands 1-13
Exercise – Workshop 1 1-16
2 Conditional Constructs and Loops
What is in this Section 2-3
FOR/END Loop (Numeric Iteration) 2-4
FOR /END Loop (Object-Based) 2-8
WHILE/END 2-11
IF/THEN/ELSE 2-13
Exercise – Workshop 2 2-16
3 Macros: Overview
What is in this Section 3-3
Macro Overview 3-4
Macro Object Parameters 3-7
Ways to Create Macros 3-8
Executing Macros 3-11
6 Dialog Boxes
What is in this Section 6-3
Adams/View Interface Overview 6-4
Terminology 6-5
Working with Dialog Boxes 6-6
Modifying Existing Pre-Built Dialog Boxes 6-7
Modifying Dialog Boxes that Were Auto Generated Using Macros 6-8
Creating Dialog Boxes from Scratch Using the Dialog Box Builder 6-9
Dialog Box Builder Overview 6-10
Dialog Box commands 6-14
Dialog Box Database Storage 6-16
Exercise – Workshop 6 6-17
7 Dialog Box Builder
What is in this Section 7-3
Substituting Text into Commands 7-4
Working with Dialog Boxes 7-8
Buttons 7-9
Radio Boxes 7-10
Sliders 7-11
Containers 7-12
Option Menu 7-13
Saving Dialog Boxes 7-14
Exercise – Workshop 7 7-15
• Examples:
– 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 (!).
– marker delete marker_name=.mod1.par4.mar27
– marker delete &
– marker_name=.mod1.part4.mar27
– mar del mar=.mod1.par4.mar27
– mar del mar=mar27
• Command Navigator
• Command Window
• Log file
• Command Navigator
– Enables you to browse through the Adams/View command language and
execute commands.
• The entire Adams/View command language is accessible through the Command
Navigator.
• Use the Command Navigator to navigate on keywords.
• Double-clicking the last keyword of a command displays a dialog box of
parameter names and parameter values.
• Command Window
– Text-based way to enter commands.
– Assumes that you understand the Adams/View command language.
Input
field
• Log file
– 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.
– Contains commands that you entered and messages you received.
– The log file for the previous session is aview.log% on UNIX and aview.log
on Windows.
• Conditional constructs
– Adams/View command language contains commands for creating
conditional constructs and loops.
• BREAK
• CONTINUE
• IF/ELSEIF/ELSE/END
• FOR/END
• RETURN
• WHILE/END
• Overview
– The FOR and END commands allow you to execute a group of commands
a fixed set of times.
– This example performs numeric iterations. 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).
• Syntax
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.
• Syntax continued
– 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.
• Example
– 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
part’s 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
• 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).
• Syntax
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 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.
• Example
– In this example, Adams/View renumbers the ADAMS IDs of markers
belonging to the part follower; it starts at 5000 and increments 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
• 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).
• Syntax
WHILE CONDITION=(expression)
...
END
• Example
– 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
part’s 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
• Overview
– Use IF/ELSE to execute a group of commands conditionally.
– The execution of commands bracketed by IF and END depend on the value
of an expression.
• Syntax
IF CONDITION=(expression) Helpful operators for expressions:
...
END
!= not equal to
IF CONDITION=(expression) && logical AND
... || logical OR
ELSE
== equal to
...
END < less than
• Example
– 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
• Macro Overview
• Macro Object Parameters
• Ways to Create Macros
• Executing Macros
• Debugging Macros
• 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.
• Types
– Parameterless
• Executes the Adams/View commands stored in the macro.
– With parameters
• You can add parameters to a macro that will be evaluated when the macro is
executed.
• This makes the macro more generic.
• Macro editor
– Here, you enter the name of the macro and a unique command string that
executes the macro.
Command
text area
• Record/Replay
– 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.
• Reading text from a file
– 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 macro’s use.
– 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.
Command
line
• Command Navigator
– 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.
Opens this
dialog box
• Types of Parameters
• Generalized format
• Naming conventions
• Qualifiers and formats
• Default characteristics
• Examples
• Real
• Integer
• File
• Object
• String
• List
• Location
• Orientation
$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
For more examples of parameters, see the Customize tab in the ADAMS/View
online help.
• Menu Builder
• Syntax of Menu File
• Using Commands to Add Menus
Menu Button
ADM704B, Section 5, February 2013
Copyright© 2013 MSC.Software Corporation S5 - 4
SYNTAX OF MENU FILE
• 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.
• The figure below shows a portion of the Menu Builder that defines the Tools
menu in Adams/View. Below the Menu Builder is the corresponding Tools
menu as it appears in Adams/View.
Dialog
box Label
Button
Text box
Slider Option
Menu
Radio
button
Separator
Container
Toggle
button
Tool
stack
ADM704B, Section 6, February 2013
Copyright© 2013 MSC.Software Corporation S6 - 5
WORKING WITH DIALOG BOXES
Title
Dimensioning
and Positioning
Toolbar
Attribute type
selector
Attributes
indicator
Attributes
Area
• Start
– Commands are executed when object is displayed.
– Useful in initializing settings and putting default values into fields when
object is displayed.
• Execution
– Commands are executed by the dialog box when the user clicks OK or
Apply.
• Finish
– Commands are executed when object is undisplayed.
– Allows you to clean up work when object is undisplayed.
• Buttons
• Radio boxes
• Sliders
• Containers
• Option menu
• Buttons
– Buttons do not contain values.
– They simply execute commands upon single or double-clicking.
Buttons
Button
Radio
boxes
Values
Text
appearance
ADM704B, Section 7, February 2013
Copyright© 2013 MSC.Software Corporation S7 - 10
WORKING WITH DIALOG BOX OBJECTS (CONT.)
• Sliders
– Sets value of an object without having to type it in.
– Currently limited to integer values.
• Containers
– Sub-region inside dialog box window
or toolbar.
– Can hold other objects
Container for
design study
• Build Files
• Adams/View Startup Files
• Locations:
– Adams/View will read in the first startup file it encounters with the correct
name (Aview.bin, AviewBS.cmd, Aview.cmd, and so on).
– Adams/View searches first for these files in your current working directory.
– If these files do not exist in your local working directory, Adams/View
searches for them in your directories specified in the aview.pth file.
– The aview.pth file is located by default in your <install>/common directory.
• Check on the plugin and hit OK to load the plugin. Verify that the
plugin library is loaded, then test the customization in the library.