Sunteți pe pagina 1din 12

Autodesk Moldflow Insight 2012

AMI Automating Autodesk Moldflow Insight Tutorial

Revision 1, 30 March 2012. This document contains Autodesk and third-party software license agreements/notices and/or additional terms and conditions for licensed third-party software components included within the product. These notices and/or additional terms and conditions are made a part of and incorporated by reference into the Autodesk Software License Agreement and/or the About included as part of the Help function within the software.

Contents

Chapter 1 Chapter 2 Chapter 3 Chapter 4 Chapter 5

Creating a project. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 Creating a macro. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2 The command line. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4 More command line scripts. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6 Tutorial review. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8

iii

iv

Creating a project

In this task, you will create a project, import a study and familiarize yourself with the geometry of the meshed model in preparation for the tasks ahead. 1 2 3 4 5 Click (Get Started tab > Launch panel > New Project). Enter API in the Project name text box. Click OK. Click (Home tab > Import panel > Import). Navigate to the Tutorial folder where Autodesk Moldflow Insight is installed, typically C:\Program Files\Autodesk\Moldflow Insight xxxx\tutorial, where xxxx is the software version. In the Files of Type drop-down list, select Study Files (*.sdy). Select cushion_3D.sdy and then click Open. Click Orbit and rotate the model to examine its geometry and features. Notice in the Study Tasks pane that the tutorial model is represented by a 3D Mesh.

6 7 8

NOTE: Before you can run a Macro or Command script, Autodesk Moldflow Insight must be open with the relevant study in that Project. In the next task, you will be introduced to the Macro Recording menu features and learn how to record and play a macro. Click the Next topic link below to move on to the next task of the tutorial.

Creating a macro

2
Translate from

In this task, you will use the Macro Recording menu features to perform a basic remodeling task. You will then play the Macro and be introduced to the two types of folders used for storing Macro scripts. 1 2 3 4 Enter -5 -20 0 in the Rotation Angle). Click Click Rotation Angles box (View tab > Viewpoint panel >

(Tools tab > Automation panel > Record Macro). (Home tab > Create panel > Geometry) to open the Geometry tab.

Click (Geometry tab > Utilities panel > Move) and select the drop-down menu. The Translate pane opens on the Tools tab.

5 6 7

From the Filter drop-down menu on the Translate pane, select Nearest Node. Click in the Select text box on the Translate pane. Hold down the Ctrl key and select the nodes shown in the following image:

Click in the Vector (x, y, z) box on the Translate pane. Ignore the Measurements dialog if it appears.

2 | Creating a macro

9 Type 0 0 0.5 (mm) in the Vector (x, y, z) box. 10 Click Apply, then click Close. 11 Click (Tools tab > Automation panel > Stop Recording).

The Save Macro dialog appears. 12 Enter task_extend in the File name box and click Save. You have just recorded this sequence of actions. You can now reproduce this sequence of actions any time you wish by running the macro that you saved. To illustrate this, reset the model to its original condition using the steps below, and then run the macro. 13 Click (Undo) on the Quick Access toolbar. 14 Click Deselect All from the Selection drop-down menu (Geometry tab > Selection panel > Deselect All). 15 Click Front View on the ViewCube. You have now returned the model to its original state. 16 Click (Tools tab > Automation panel > Play Macro).

The Open Macro dialog appears. Move the dialog to the side so that you can see the model. 17 Select the macro file you just created and click Open. The macro plays and extends the nodes. Rotate the model to observe the changes. 18 Click state. (Undo) on the Quick Access toolbar to return the model to its original

When you stopped macro recording and saved the macro, you saved it to the scripts directory under your project home directory, as specified when Autodesk Moldflow Insight was installed. This setting can be changed on the Directories tab of the Options dialog ( Options).

In the next task, you will run another type of script from the Command line and be introduced to the commands folder also located in the same directory as your script folder. This is where all the command line scripts are saved. Each script can be activated through the Command Line feature. Click the Next topic link below to move on to the next task of the tutorial.

Creating a macro | 3

The command line

In this task, you will run a VB script from the Command Line to set multiple injection points on the model. 1 Ensure the cushion_3D study used in the previous task is open.

2 3 4 5

Using the Click

ViewCube click Front View . (Home tab > Create panel > Geometry) to open the Geometry tab.

Click (Geometry tab > Selection panel > Select Facing Entities) to ensure that only the elements facing you will be selected. Click (Geometry tab > Selection panel > Select Enclosed Entities) to ensure that only the elements that are fully enclosed within a banding box will be selected. Click (Geometry tab > Selection panel > Circle). Click and drag the cursor starting at the node in the center to select the nodes and elements shown in the following image.

6 7

4 | The command line

8 9

Click (View tab > Windows panel > User Interface) and select Command Line from the drop-down menu. Type INJPTS_3D and click Go, or press Enter. NOTE: When entering the name of a command script in the Command Line dialog, do not include the file extension (*.vbs).

10 If you are asked whether you want to Use Injection Face Normal: 0, 0, 1?, click Yes. 11 When the script has completed, a Completed dialog appears. It states 19 nodes selected. Click OK on this dialog. You should see that injection points have been inserted at all of the nodes you selected. 12 Click clearly. Orbit to rotate the image so that you can see the injection points

TIP: You can verify that these commands have been run by clicking Action History on the Quick Access toolbar. 13 If you wish to view the Visual Basic code for this script, locate it using Windows Explorer and open it in a text editor. NOTE: If you installed Autodesk Moldflow Insight in the default installation directory, the INJPTS_3D script will be located at C:\Program Files\Autodesk\Moldflow Insight xxxx\data\commands\injpts_3d.vbs. This script is one of a set of scripts that are installed with Autodesk Moldflow Insight. This package of prewritten scripts is stored in the Commands folder. Any VB scripts that you write yourself or record using the Record Macro function are stored by default in the My AMI xxxx Projects\scripts directory. 14 Click Front View on the ViewCube to return the model to the front view.

In the next task, you will learn about the other command line scripts that are installed with the product. Click the Next topic link below to move on to the next task of the tutorial.

The command line | 5

More command line scripts

In this task, you will explore the other VB scripts that are installed with Autodesk Moldflow Insight, and learn how to access the help documentation for some of the other VB scripts. 1 2 3 Click (View tab > Windows panel > User Interface) and select Command Line from the drop-down menu. When the Command Line dialog appears, type HELP into the text field and click Go. A text file opens. This file contains a brief description of the function of each VB script that is supplied with the product. Read through the file to learn what other functionality is available through these VB scripts. Close the text file when you have finished.

Some of the VB scripts that are installed with Autodesk Moldflow Insight require you to enter parameter values when you invoke the script from the command line. You will now investigate one such script, and will learn how to find out which other scripts require these values. 1 2 3 Ensure the Command Line dialog is open. Type HELP DT into the text field and click Go. A dialog opens. This dialog contains a synopsis of the information necessary to run the script successfully, including:

Information about what function the script performs (DESCRIPTION) Information about what you must type in on the command line to launch the script (SYNTAX) Information about any parameter values that you need to type in on the command line when you run the script (PARAMETERS) Any further information about the script (NOTES)

4 5 6

You can see that the DT script translates (pans) the model horizontally and/or vertically. Click OK to close the information dialog. Type DT into the Command Line dialog and click Go. A dialog appears stating that insufficient arguments were supplied. Read the comments on the dialog and then click OK. The script failed to run because no translation values between -1 and 1 were entered. You will now enter these values and rerun the script.

7 8

Click OK to close the information dialog. Type DT 0.5 0.5 into the text field on the Command Line dialog and click Go.

6 | More command line scripts

The first value is the translation amount in the horizontal direction, while the second value is the translation amount in the vertical direction. The model will be translated half way across the screen to the right and half way up the screen. 9 Type DT 0.5 into the text field on the Command Line dialog and click Go. The model will now be translated across the remaining right half of the screen until it is completely out of sight. 10 Type DT -1 -0.5 into the text field on the Command Line dialog and click Go. The model will be translated back to the center of the screen. NOTE: To learn whether any other scripts require command line parameters, type HELP <script name> in the Command Line dialog. The resulting dialog will explain what parameters (if any) are required. Some scripts, such as the INJPTS_3D script that you ran earlier in this tutorial, do not require any command line parameters. More detailed information on the API is provided in the API section of the online help. There you will find extended information about how to use the API, examples of API VB scripts, references for Visual Basic programming, and the API command reference.

More command line scripts | 7

Tutorial review

This tutorial has given you an overview of the functionalities available in the Application Programming Interface (API) within Autodesk Moldflow Insight. You have:

Created a macro. Run VB scripts.

8 | Tutorial review

S-ar putea să vă placă și