ADAMS/Viewcommandlanguageandstructure¾Commands(命令) –keywords (关键字), parameter names (参数化名字), parameter values (参数化值)¾Cditiltt(条件式命令结构)¾Conditional constructs (条件式命令结构)(if/then/else, for loops, etc.)¾利用command files (.cmd) 来执行命令2关于Adams/View命令3Adams/View命令的语法规则(1)4Adams/View命令的语法规则(2)5输入值的语法规则6.log文件不知道的命令可由此文件来获得7不知道的命令可由此文件来获得ADAMS/Viewcommand的三种类型8ADAMS/Viewcommand中的conditionalconstructs¾BREAK¾BREAK¾CONTINUE¾IF/ELSEIF/ELSE/END¾FOR/END/¾WHILE/END¾RETURN¾RETURN9Conditionalconstructs-BreakBREAK运用BREAK 命令可以立刻停止执行循环里的命令,从FOR或WHILE循环中跳出来。当/在个循环里遇到个命令时它就会立马退出来当Adams/View在一个循环里遇到一个BREAK命令时,它就会立马退出来而不执行循环中剩余的命令。The BREAK command affects only the innermost FOR or WHILE loop.BREAK命令在只影响昀内部的FORWHILE循环BREAK命令在只影响昀内部的FOR or WHILE循环。Examplevariablecreatevariablename=ipintegervalue=0variable create variable_nameip integer_value0while condition=(ip 5)variable modify variable_name=ip integer_value=(eval(ip+1))if condition=(eval(DBEXISTS (MAR//ip)))ifcondition(eval(_XISTS(MAR//ip)))breakendmarker create marker_name=(eval(MAR//ip)) &_((p))location=(eval(ip‐1)),0,0endvariable delete variable_name=ip10Conditionalconstructs-CONTINUE利用CONTINUE命令用来跳过昀里层的FO或者WHILE循环中的命令继续执行循利用CONTINUE命令用来跳过昀里层的FOr或者WHILE循环中的命令,继续执行循环中的下一个新的迭代。当Adams/View 在循环中遇到一个CONTINUE 命令时,它将跳过循环中剩余的命令,直接到昀内层循环中的END命令并继续执行新的一轮循环直接到昀内层循环中的END命令,并继续执行新的一轮循环。CONTINUE命令在只影响昀内部的FOR or WHILE循环。Examplevariable create variable_name=ip integer_value=0while condition=(ip 5)bldfbll(l())variable modify variable_name=ip integer_value=(eval(ip+1))if condition=(ip == 3)continuedendmarker create marker_name=(eval(MAR//ip)) &location=(eval(ip‐1)),0,0endendvariable delete variable_name=ip11Conditionalconstructs-IF/ELSEIF/ELSE/ENDif condition=(DB_EXISTS (MAR1))marker modify marker=mar1 location=2,0,0elseelsemarker create marker=mar1 location=2,0,0end!Bodies! Bodiesvariable create variable=object_type string=(eval(DB_TYPE(.MDI.obj)))if condition=(object_type == marker)interfacecommandbuildercommand=markermodifymarkerinterface command_builder commandmarker modify marker initial=(.MDI.obj)elseif condition=(object_type == point)interface dialog display dialog=.gui.mainobjecttable gpygg_jparameter=Pointselseif condition=(object_type == flexible_body)interface dialog display dialog=.gui.flx_dia_panel parameter=(.MDI.obj)12endConditionalconstructs-三元表达式variable set variable = variable_min & real = (EVAL((variable_a variable_b)?variableavariableb))variable_a : variable_b))13Conditionalconstructs-FOR/END(1)ExamplesofNumericIterationforFOR/END:Examples of Numeric Iteration for FOR/END:forvariable_name=tempreal start_value=1end_value=10marker create marker_name=(eval(MAR // RTOI(tempreal))) <i(l(tl1))00location=(eval(tempreal‐1)), 0, 0end数字型的循环14Conditionalconstructs-FOR/END(2)variable create variable_name=ip integer_value=5000forvariablenamethemarkerobjectnamesfourbarfollower*typemarkerforvariable_name=the_marker object_names=.fourbar.follower.* type=markermarker modify marker_name=(eval(the_marker)) adams_id=(eval(ip))variable modify variable_name=ip integer_value=(eval(ip+1))endendvariable delete variable_name=ip对象(object)型的循环15Conditionalconstructs-WHILE/ENDExamplespvariable create variable_name=ip integer_value=0whilecondition=(ip 10)marker create marker_name=(eval(MAR//ip+1)) &location=(eval(ip)),0,0variable modify variable_name=ip integer_value=(eval(ip+1))endvariable delete variable_name=ip16Conditionalconstructs-return利用RETURN命令将退出其所在的命令文件或宏命令。如果RETURN 是在循环中执行,它将退出所有的循环,并执行所有的清理工作。在一个文件中可以有多个RETURN存在。if condition=(DB_COUNT(.SELECT_LIST, objects_in_group)==0)mdi gui_utl_alert_box_1 type=Error text=Select List is empty. Select objects first.returnend !if!info empty!list_info group &group_name = .SELECT_LIST &brief = on &write_to_terminal = on!17利用commandfiles执行一个任务-履带车1.016910.966SprocketUpperRollerIdlerChassisTensioner0.21450.27140.050.050.173.1730.0.290.290.290.290.6750.675LowerRoller0.0250.5550.555LowerRollerTrackLink42个track link,程序自动化建模,共1078行代码共1078行代码。18履带车-刚体1.016910.966SprocketUpperRollerIdlerChassisTensioner0.21450.27140.050.050.1730.1730.0250.290.290.290.290.6750.675LowerRoller0.5550.555TrackLink19履带车-约束20履带车-碰撞力21履带车.cmd文件解读(1)解释性函数在文件中用来命名解释性函数:sout,在文件中用来命名sout(%s.cm,bd)数组变量定义22履带车.cmd文件解读(2)几何参数设置几何参数设置23履带车.cmd文件解读(3)碰撞力参数设置碰撞力参数设置24履带车.cmd文件解读(4)利用循环建立刚体利用for循环建立刚体25履带车.cmd文件解读(5)利用for循环中的变量k获取数组中的变量,并对刚体属性赋值26履带车.cmd文件解读(6)利用for循环建立铰链27履带车.cmd文件解读(7)利用for循环建立力28履带车.cmd文件解读(8)建立驱动drvω29履带车.cmd文件解读(9)分析参数设置30履带车.cmd文件解读(10)request输出设置31宏、自定义菜单和对话框•Themacrolanguageandmacrostructure.•Howtocreateandaccessmacrostoautomatecommontasks.•CreatingcustomdialogboxesCreatingcustomdialogboxes•Usingthedialogboxbuilder•Defininglabels,fields,buttons,optionsmenu,etc.•Becomefamiliarwithunderlyingcommandsyg•Creatingcustommenus.•Puttingitalltogethertobuildacustominterface.32ADAMS/View的宏•使用ADAMS/View的宏/•关于ADAMS/View的菜单和对话窗……•使用MenuBuilder修改菜单;•使用Menu Builder 修改菜单;•使用Dialog‐Box Builder 自定义对话窗如何使用ADAMS/View的宏•可以使用宏自动完成一些重复性的过程,可以记录、编辑、存储或执行宏。–ADAMS/View宏介绍ADAMS/View宏介绍–生成、删除、存