You are on page 1of 10

Chapter 14 Programming in Pro/E

From Computer Aided Design with Pro/Engineer (Part, Sketcher, Detail, Assembly, Mechanica, and Manufacturing) by Meung J. Kim, Ph.D., Professor Department of Mechanical Engineering Northern Illinois University 14-1 Introduction
Pro/E allows users interactivley programming at two levels. At lower level a micro programming environment, Pro/E PROGRAM Tool, is supported while at the higher level, C/C++ programs are supported through Pro/ENGINEER Application Programming Interface (API) Toolkit. These programming environments serve different needs. Some manipulations by PROGRAM includes:

Delete a feature or component Reorder a feature or component Suppress a feature or component Resume a feature or component Modify a dimension and add a new instance Pause the regeneration with an INTERACT statement anywhere in the model section

14-2 Pro/PROGRAM In Parts


Pro/PROGRAM is Pro/ENGINEER's internal relational language. It allows users to create advanced relationships to control the parts, as well as conditional relationships that allow users advanced control over part and assembly features and construction. It allows the automation of repeated tasks and similar assemblies. Thus, it supports quick and relatively straightforward interactive programming. The programming is done simply in any text editor such as Microsoft Notepad. User can start the Pro/E PROGRAM by clicking Tools > Program from the PART or ASSEMBLY mode. A typical Pro/E PROGRAM routine may contain any of the following: Input variables Relations IF-ELSE clauses Lists of all the features, and parts INTERACT statements MASSPROP statement Input Variables INPUT variables may be specified at the beginning of the listing; and their values can be provided by the user at the beginning. The INPUT has the format INPUT Variable_Name Variable_Type

END INPUT The INPUT statement must define the name and type of the variable. Variable names must always begin with a character. The following variable types are supported: Number String: This enables the user to enter parameters or model names. Logical (YES_NO): Enter either Y or N. An example program can be written as INPUT WIDTH NUMBER "Enter the width of the plate" END INPUT For RELATIONS, the next chapter can be referred to. Suppose the part below must be controlled by width, height, and the depth of the plate so that all other features could be scaled to these values.

1. Create the part first with holes separately 2. Edit (click select the part and then double click) > click select the width dimension and RMB > Properties > click Dimension Text tab > change the default to WIDTH > OK 3. Repeat this for the height and the depth dimensions with names of HEIGHT and DEPTH 4. Tools > Relations > click all features one by one to display the names. It appears as the second figure above. Screen capture or print the screen and remember the names > OK 5. Tools > Programs > Edit Design > (From File) > the editor displays the program of the part as

Figure 14.2.1 Pro/E Program 6. Enter the INPUT and RELATIONS as shown. Note the actual dimension names may be different in your model > File > Save 7. Yes (to incorporate the changes) 8. Now, the menu manager reflects the changes in the program with the input as

9. This INPUT menu will appear whenever Regenate menu is used. Click Enter > Select All > Done Sel > enter new values, say, width=150, height=100, depth=50, and see the changes.

10. All features were scaled by Relations except the holes. Tools > Relations > the relations we entered in the program appear here. Add the relations for hole diameters as shown below > OK

Figure 14.2.2 Relations dialog 11. Regenerate > Current Values > the model resizes to the current dimension values of the plate. It appears as above 12. The Relations in the Relations dialog do not appear in the Program. We may want to move them to the program in one place by Cut in Relations dialog and then Paste in the program.

14-3 Pro/PROGRAM In Assembly with Instances


Pro/PROGRAM can be also very helpful in assembly that may have various sizes of one component to be assembled to various sizes of other components. Suppose the following two parts be assembled, pivot and driver.

Figure 14.3.1 Pivot-Driver Assembly More often than not, the design changes and is tested with different sizes. If the size of the hole in the pivot changes, then the size of axial cylinder in the driver must change accordingly. How can this be accomplished interactively in the assembly? The following explains procedures for the the assembly above by [File > New > Assembly > open an assembly file > complete the assembly] 1. First create a parameter (i.e., variable) in the assembly that will be used in the program. Tools > Parameter > in the dialog, Add > change the name to asm_radius and enter the current value 0.25 > OK (close) 2. In Model Tree, click the pivot > RMB > Open to open the part > Edit > select the hole radius dimension > RMB > Properties > Dimension Text tab > change the name under Name to pivot_radius > OK 3. Create the input variable in the program to be used in the assembly. Tools > Program > Edit Design > now, the program opens in a text editor > type in the input and relation statements as

Figure 14.3.2 Pivot Program Note that the HOLE_RADIUS in the program is the gateway (i.e., passing argument in programming languages such as C/C++) to actual variable PIVOT_RADIUS. 4. File > Save > Exit 5. Yes (to incorporate the changes) 6. Now, the menu manager has additional menus as shown

7. 8. 9. 10. 11.

Enter Vals > check PIVOT_RADIUS / Done Sel > enter the default value 0.25 Done/Return File > Close Window In the Model Tree, select the driver > RMB > Open Lets create a symbolic name for the radius of the axial cylinder as before > Edit > click the radius dimenion > RMB > Properties > Dimension Text > change the name to DRIVER_RADIUS > OK

Family Tables

Instances of the program run can be permanently saved as the version of the model by using the Instantiate option in the PROGRAM menu. The system adds the instances to the family table for that version. 12. Create a family table that will be looked u for correct size of this part by the assembly program later > Tools > Family Table > in the family table (see below), New Instance > New Column > in another dialog Family Items, pick the model in the window and then the radius dimension of the axial cylinder > it is now added to the Family Items as

Figure 14.3.3 Family Items dialog 13. Back in the family talbe, enter a value 0.12 in the new instance for radius > CR > enter values repeatedly as shown in the family table below

Figure 14.3.4 Family Table Note that the variation of radius in the part must not exceed the size of the bar for successful regeneration. 14. File > Close 15. If the driver.prt is needed, open the generic part. 16. Now, back to the assembly

17. Tools > Program > Edit Design > change the program as shown below

Figure 14.3.5 Assembly program with Input, Execute, Relations, and LOOKUP_INST function Pay close attention to the program how it handles input, assign the input to the input variable of the PIVOT, look up the appropriate instance from the family table by LOOKUP_INST function in Pro/E, and finally the retrived instance is added. The DRIVER_INSTANCE is the instance that is obtained by the function LOOKUP_INST.

The LOOKUP_INST function allows a family table instance to be chosen based on various parameter values. From the online help we find the format as. lookup_inst ("generic_name", match_mode, "param_name_1", match_value_1, "param_name_2", match_value_2,...) where generic name - Name of the generic model with a .prt or .asm extension match_mode - One of the following values: 1 (find closest instance with param values less than or equal to supplied values) 0 (find instance with param values that match supplied values exactly) 1 (find closest instance with param values greater than or equal to supplied values) param_name_1 - Family table parameter name match_value_1 - Value to match against
The first argument must be the filename for generic part, the next argument can be -1, 0, 1. -1 is the instance that is equal or less than the input parameter, ASM_RADIUS_INPUT, in this case, 0 is the instance that is equal to the input parameter, and +1 for greater than or equal to the input. The next argument is the parameter of the family table. The final argument is the input parameter against which the function looks up the appropriate instance from the table. 18. File > Save > Exit

19. Yes (incorporate the change) > Enter > Select All / Done Sel > enter 0.33 > CR 20. See the change of the radius of the pivot and the instance added that has 0.29 radius smaller than the input 0.33

Figure 14.3.6 Regenerated pivot and corresponding driver instance 21. Use Regenerate to change the radius anytime the design changes

14-4 Pro/PROGRAM In Assembly with Regeneration


The previous assembly demonstrated how to use instances of a component, driver.prt, when another component, pivot.prt, changes. In this section it is demonstrated how the assembly can regenerate both components. The figure below shows the gear-shaft assembly that is regenerated with two different diamters of the shaft.

1. Create the part, prog-shaft.prt, as shown above 2. Change the Name of shaft diameter of size 4.0 to SHAFT_DIAMETER 3. Tools > Program > Edit Design > edit the program as

The variable YN in the INPUT is used to skip the input prompt. 4. File > Save > Exit > Yes (incorporate) > Enter > select the diameter > Done Sel > enter 4.0 > CR > Done/Return 5. File > Close Window 6. Create the part, prog-gear.prt as shown (the gear profile is not used and can be simplified) 7. Change the Name of shft hole in the gear to GEAR_DIAMETER 8. Edit the program as

9. Save and exit the file and then enter a default value 4 > Done/Return 10. File > Close Window 11. File > New > Assembly > enter a name and open the file 12. Add a Component > add the shaft file > constrain both coordinates wth Coord System > Done 13. Add the gear file > constrain both axes with Align and both faces with Align with Offset = 0.5 > Done

14. Now, edit the program as

Note that YN = NO is used to suppress the input prompt in the parts. 15. Save the program and exit > Yes (to incorporate) > Enter a value, say, 6.0 > CR > see the both parts change the size and fit together 16. Regenerate > try another value

You might also like