Download presentation
Presentation is loading. Please wait.
1
Workshop 1 understanding the command language
3
Workshop Objective Software Version Files Required
To learn Adams/View command Language To learn how to write a command file Software Version Adams 2012 Files Required wing_retractor_start.cmd
4
Suggested Exercise Steps
Importing the model Model verification Command history Command completion Using the command navigator Executing commands in a file Using expressions in commands Modify the command file Writing a command files Optional tasks
5
Step 1. Importing the Model
To import the model Start Adams/View from the mod_01_cmd_lang directory. Import the wing retraction model, wing_retractor_start.cmd.
6
Step 2. Model Verification
Executing a simple command In the “Complete Multibody Dynamics Analysis with Adams” 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. Learning Adams Command language will make you a better Adams/View user. Verifying a model 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.
7
Step 2. Model Verification (Cont.)
To verify the model: Display the Command Window so that you can see commands echoed to the screen. From the View menu, select Command Window (or you can use the F3 shortcut key). Input field
8
Step 2. Model Verification (Cont.)
Verify the model by right-clicking the icon in the Status Bar and then selecting the Verify tool. From the Tools menu, select Model Verify. This also verifies the model. Look in the Command Window. What is the command for verifying a model? _____________________________________________________ In the text box at the bottom of the Command Window, type the command for verifying a model and then select Enter. Did it verify the model the same as it did using the interface? _____ Yes _____ No
9
Step 3. Command History Command history example
The command line input field has helpful features, such as command completion and command history. Let’s use some of these features. To use the command line with history: Place your cursor in the Command Window and click in the input field to activate the window. Click the Up arrow, on your keyboard, to see the last command entered: it should be model verify. Press Enter. Adams/View executes the command. Notice that the Information Window has become cluttered with multiple verify operations. Clear the contents by selecting Clear in the Information Window. What was the command that cleared the window? _____________________
10
Step 4. Command Completion
Command completion example 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 command completion to close the information window when you know the first character of the command: Enter the following two characters into the Command Window: in 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. 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.
11
Step 4. Command Completion (Cont.)
Enter another question mark or the Esc key. The Command Window shows the parameters that are now available. They are: close, empty, and read. Note: Occasionally, you may run across commands in the interface that are no longer being used. Complete the command that will close the information window and then select Return to execute this command. To use the command completion to close the information window when you don’t know the first character of the command: 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? Clear the contents of the command line. 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
12
Step 4. Command Completion (Cont.)
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 weren't any equivalent commands. There are some Adams/View interface operations that are done in code that are neither shown to you nor echoed to the Command Window.
13
Step 5. Using the Command Navigator
Quite often you will see that there are multiple paths to the same command. Earlier you saw that the Adams/View interface has more than one way for you to verify a model, but each of these 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 Command Navigator to turn off the appearance of a marker icon: If the model icons are not already visible, turn them on by clicking the “V” key on the keyboard. From the Edit menu, select Appearance. In the Database Navigator, browse to and then select PART_12.cm. In the dialog box that opens, set Visibility to Off and select Apply.
14
Step 5. Using the Command Navigator (Cont.)
Look at the command that was issued in the Command Window: This is the command you want to issue by using the Command Navigator. Undo the command so the marker is visible again. (Select Undo from the Main Menu) Display the Command Navigator by selecting Command Navigator from the Tools menu. Select entity and then attributes. The Entity Attributes dialog box opens.
15
Step 5. Using the Command Navigator (Cont.)
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.
16
Step 5. Using Command Navigator (Cont.)
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 06 , Working with Dialog Boxes. Tip: Auto-generated dialog boxes may not always display the correct options and text box values. If you place your cursor in the Entity Name text box and press Enter, the information will update with the correct information. Complete the Entity Attributes dialog box (shown on previous page on the left) the best you can and see if you can turn off the visibility of the marker PART_12.cm. Tip: Use Visibility instead of Expr Visibility.
17
Step 5. Using Command Navigator (Cont.)
To use the Command Navigator to turn off the appearance of more than one marker icon: 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 (*). Turn off all markers using a wildcard: Entity Name: .model_1.* Type Filter: marker Visibility: off Name Visibility: off Note: If the which.model_1*.? dialog box appears, do not select anything but select OK. Select OK. Notice all the markers have turned off. If you want to learn about other wildcards, see the Adams/View online help. Adams/View > Learning Basics > Overview>Using wildcards
18
Step 6. Executing Commands in File
Executing commands in a file 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 execute commands in a file: Look in the Command Window until you find the commands that just turned off the marker visibility with the wildcard. Highlight the commands, right-click, and then select Copy. Selecting Copy places them on the clipboard. 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.
19
Step 6. Executing Commands in File (Cont.)
Edit the text, changing the visibility parameter to on, instead of off. Save the file as all_markers_on.cmd. Import the file to execute the commands. The markers turn on. Modify the file, changing the visibility to off. Save the file as all_markers_off.cmd. Import the file to turn off the marker visibility using the F2 keyboard shortcut. The markers turn off again. Look at the command files you have just written, will they work as written on a model that is named .model_2? _____ Yes _____ No
20
Step 6. Executing Commands in File (Cont.)
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.
21
Step 7. Using Expressions in Commands
Using expressions to make commands more generic In the ADM704A course workshop 4, Parameterizing an Exisiting 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 it’s named .model_1, .sla, or something else. Let's briefly look at the command language and expression syntax that was used. To look at the command language: Open the file utils/ctr_mar_on.cmd. This file uses a for-loop construct. You will learn more about that later in Workshop 02, Conditional Constructs and Loops. For now, we will concentrate on the expression.
22
Step 7. Using Expressions in Commands (Cont.)
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 on.
23
Step 7. Using Expressions in Commands (Cont.)
Turning off the visibility of geometry using a command file Here, you will turn off the appearance of all the links, cylinders, extrusions, and ellipsoids for a given model in a generic way like you've just seen with the nested expression. An example of this is provided in your mod_01_cmd_lang directory. To turn off the visibility of geometry: Using a text editor, open the file rigid_geom_off.cmd. Review the commands and see if they make sense to you. Each piece of geometry is handled with its own command. Based on these commands, which of the following geometry types will be turned off? ____ Link ____ Extrusion ____ CSG ____ Cylinder ____ Ellipsoid ____ Plate
24
Step 7. Using Expressions in Commands (Cont.)
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. Turn off all icons using the v keyboard shortcut. Notice that some of the geometry still remains, as shown below.
25
Step 7. Using Expressions in Commands (Cont.)
What kind of geometry is still displayed? Circle the best answer. Tip: Getting information on a piece of geometry will give you a clue. Link Extrusion CsgSolid Plate Next you will need to modify the command file so it will turn off the visibility of the CsgSolid geometry.
26
Step 8. Modify the Command File
To modify the command file: Using a text editor, add to the file rigid_geom_off.cmd 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. Save your changes. Test the file by importing it. Did the CsgSolid geometry visibility turn off? _____ Yes _____ No Modify the file so that it will turn the geometry back on and then save it as rigid_geom_on.cmd. Import the file rigid_geom_on.cmd. Your geometry should be visible again.
27
Step 9. Writing Command Files
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.
28
Step 9. Writing Command Files (Cont.)
Task 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 wing’s tip during animation. Note: Do so by only reviewing the Command Navigator and dialog box for keywords and parameters not by executing the command (via the Adams/View interface command line, etc.). Import this command file. Did it work as expected? _____ Yes _____ No
29
Step 9. Writing Command Files (Cont.)
Task 2 Write a command file named task_2.cmd that: Sets the Update Graphics to Never. Submits a transient simulation (2sec/100steps). Resets the simulation. 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. (Tip: Look for the number_of_cycles parameter used in a standard simulation command.) Pauses. (Tip: Use the Pause command.) Numeric_results - list_info - all for the result_set_component JOINT_9.FX, and save as joint_9_info.txt. Sets view window to model display. Sets execution display back to update at every output step. After you have written the command file, modify it as needed and save it as task_2_batch.cmd. The most common mistake is forgetting to include a file command read file=... command to import the wing model first.
30
Step 9. Writing Command Files (Cont.)
Run it in batch mode: adams2012_X64 aview ru-s b task_2_batch.cmd exit Review the aview.log file to confirm that there were no errors in the batch file. Proceed to the next page for the final team task.
31
Step 9. Writing Command Files (Cont.)
Task 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 are not hooked up with the correct commands and you'll receive errors when you try to use them. See if you can find the broken buttons and then fix them (by hand-editing the command file) so that it works properly. Save the repaired file as task_3_dbox_visibility.cmd. Would this customized dialog box be useful in your everyday Adams/View 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 should’ve been removed)
32
Step 10. Optional Tasks Optional tasks
Modify rigid_geom_on.cmd and rigid_geom_off.cmd so that they also handle the plate geometry type. Search the knowledge base and find KB 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. Save the file as constraints.cmd. Tip: To see all the database types, you can use the procedure outlined in KB Step 2: If the Knowledge Base is inaccessible, see the directory, completed/optional/kb7954.
33
Step 10. Optional Tasks (Cont.)
Write a command file results_image_batch.cmd that does the following (simple steps are provided): Import parameterized model mod_01_completed.cmd. From the File menu, select Import. Render model smooth shaded. From the View menu, point to Render Mode and then select Smooth Shaded. Set to front view. From the View menu, point to Preset and then select Front. Change a design variable. From the Build menu, point to Design Variable and then select Modify. Run a simulation. From the Simulate menu, select Scripted Controls. Animate with traces on. From the Review menu, select Animation Controls. Fit to view. From the View menu, point to Position/Orientation and then select Fit.
34
Step 10. Optional Tasks (Cont.)
Zoom out two times. From the View menu, point to Position/Orientation and then select Zoom Out. Create .jpg hardcopy of view window. From the Tools menu, point to Command Navigator and then select hardcopy
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.