• | Push button—A named item in a group or menu that is used to launch a set of instructions. An example is the Plane button in the Datum group. Check button—An item in a group or menu that may be toggled on and off. An example is the Plane Display toggle in the Model Display group in the View tab.
|
• | Radio group—An item in a group or menu that may be set to one and only one of any number of options. An example is the group of windows listed in the Window group at the Windows tab which allow you to switch between different windows. |
• | Command—A procedure in Creo Parametric that may be activated from a button. |
• | Command ID—An opaque pointer to a command, used as an input to other Creo TOOLKIT functions. |
• | Action command—A command which executes a set of instructions. Launched by push buttons. |
• | Option command—A command which executes a set of instructions based on the state of a UI component. Commands are launched by check buttons and radio groups. |
~ Command `ProCmdModelSave`
1. | Define the action command to be initiated by the button. The action is defined in a function known as the “callback function.” |
2. | Designate the command using the function ProCmdDesignate(). |
3. | Add the button to the ribbon user interface using the using the Customize Ribbon tab in the dialog box. This operation binds the added action to the button. |
ProError ProCmdActionAdd (
char *action_name,
uiCmdCmdActFn action_cb,
uiCmdPriority priority,
uiCmdAccessFn access_func,
ProBoolean allow_in_non_active_window,
ProBoolean allow_in_accessory_window,
uiCmdCmdId *action_id );
• | action_name —The name of the command as it will be used in Creo Parametric. This name must be unique, and it must occur only once in your applications or in Creo Parametric. To prevent conflicts, PTC recommends prepending or appending a unique identifier to your command names, similar to ptc_openfile or openfile_ptc. |
• | action_cb—The action function (callback function) that will be called when the command is activated by pressing the button, cast to
a uiCmdCmdActFn: typedef int (*uiCmdCmdActFn) (
uiCmdCmdId command,
uiCmdValue *p_value,
void *p_push_command_data
);
|
• | priority—The command priority. The priority of the action refers to the level of precedence the added action takes over other Creo Parametric actions. The available action priorities are defined in the enumerated type uiCmdPriority. The possible values are as follows:
typedef int uiCmdPriority;
#define uiCmdPrioDefault ((uiCmdPriority) 0)
#define uiProeImmediate ((uiCmdPriority) 2)
#define uiProeAsynch ((uiCmdPriority) 3)
#define uiProe2ndImmediate ((uiCmdPriority) 5)
#define uiProe3rdImmediate ((uiCmdPriority) 6)
#define uiCmdNoPriority ((uiCmdPriority) 999) The following table describes the enumerated values in detail.
|
• | access_func—The access function (callback function) that determines if the menu button should be available, unavailable, or hidden. Action
accessibility refers to whether an added button is available for user selection. This function is called each time the button
is displayed. The accessibility is evaluated based on the conditions pertaining at the time the button is pressed. The access
function must be cast to a uiCmdAccessFn: typedef uiCmdAccessState (*uiCmdAccessFn)
(uiCmdAccessMode access_mode); The potential return values are listed in the enumerated type uiCmdAccessState:
Note
When you add a button, all the return values for the enumerated type uiCmdAccessState work as documented. However, when you add a button to the Creo Parametric ribbon user interface, and the access function returns the value ACCESS_REMOVE or ACCESS_INVISIBLE, these values are ignored. The values are treated as ACCESS_UNAVAILABLE instead. The button is visible, but is unavailable.
|
• | allow_in_non_active_window—A ProBoolean determining whether or not to show this command in any non active window. A non-active window is a window that exists and contains a model, but that is no the active window in the Creo Parametric session. A window becomes active when the user chooses . This functionality is equivalent to changing the active window by selecting and activating a window using the pull-down menu of Windows command under the View tab in Creo Parametric. |
• | allow_in_accessory_window—A ProBoolean determining whether or not to show this command in an accessory window. An accessory window is smaller than a main Creo Parametric window and allows only the File>Exit command from the menu. |
• | action_id—The function will return a uiCmdCmdId, the command identifier. This identifier can be used in additional Creo Parametric function calls, such as, ProCmdDesignate. |
• | The function ProCmdActionAdd() is executed only once per Creo Parametric session for each action. Subsequent calls to this function for a previously loaded action are ignored (therefore you cannot redefine an action within a Creo Parametric session). |
1. | Define the option command to be initiated by the button. The definition of this command includes the definition of three callback functions. |
2. | Designate the command using the function ProCmdDesignate(). |
3. | Add the check button to the ribbon user interface. This operation binds the added action to the button. |
ProError ProCmdOptionAdd (
char *option_name,
uiCmdCmdActFn option_cb,
ProBoolean boolean_operation,
uiCmdCmdValFn set_value_cb,
uiCmdAccessFn access_func,
ProBoolean allow_in_non_active_window,
ProBoolean allow_in_accessory_window,
uiCmdCmdId *option_id );
• | option_name—The name of the option command. This must be unique, in the same way as action command. |
• | option_cb—The action command to be executed when the check button is toggled, cast to a uiCmdCmdActFn. This function should include a call to ProCmdChkbuttonValueGet(), to determine the value of the check button. |
• | boolean_operation—Specifies whether or not the option has two values. Set this to PRO_B_TRUE for a check button. |
• | set_value_cb—The callback function that sets the value of the check button, cast to a uiCmdCmdValFn: typedef int (*uiCmdCmdValFn) (
uiCmdCmdId command,
uiCmdValue *p_value
); This function should include a call to ProCmdChkbuttonValueSet() to set the value of the check button when the UI is displayed or refreshed.
|
• | access_func—The callback function that determines if the command is accessible. |
• | allow_in_non_active_window—A ProBoolean determining whether or not to show this command in any non-active window. A non-active window is a window that exists and contains a model, but that is not the active window in the Creo Parametric session. A window becomes active when the user activates a new window or opens a model in a new window. |
• | allow_in_accessory_window—A ProBoolean determining whether or not to show this command in an accessory window. An accessory window is smaller then a main Creo Parametric window and allows only the File>Exit command from the ribbon user interface. |
1. | Define the option command to be initiated by the group of buttons. The definition of this command includes the definition of three callback functions. |
2. | Designate the command using the function ProCmdDesignate() |
3. | Add the radio button group to the ribbon user interface. This operation binds the added action to the button. |
• | output_callback_function—Must include a call to ProCmdRadiogrpValueGet() to determine the selected value in the radio group. |
• | boolean_operations —Must be PRO_B_FALSE for radio groups. |
• | set_value_cb—Must include a call to ProCmdRadiogrpValueSet() to set the value of the group upon redisplay of the radio group UI. |
ProError ProCmdBracketFuncAdd (
uiCmdCmdId cmd_id,
uiCmdCmdBktFn bracket_func,
char *bracket_func_name,
void **pp_bracket_data );
• | cmd_id—The command identifier. |
• | bracket_func—The callback function to be called before and after the command, cast to a uiCmdCmdBktFn: typedef int (*uiCmdCmdBktFn)
( uiCmdCmdId command,
uiCmdValue *p_new_value,
int entering_command,
void **pp_bracket_data); The entering command argument will be 1 before execution and 0 after. If the operation is before the upcoming command execution, and you want to cancel the upcoming command execution,
return 0. Otherwise, return non-zero.
|
• | bracket_func_name—The name of the bracket function. |
• | pp_bracket_data—A void** containing data to be passed to the bracket function. |
1. | Define or add the command to be initiated on clicking the icon. |
2. | Optionally designate an icon button to be used with the command defined by you. |
3. | Designate the command (icon) to appear in the Customize Ribbon tab in the Creo Parametric Options dialog box. Note
Refer to the chapter on User Interface: Ribbon Tabs, Groups, and Menu Items for more information. Also, refer to the Creo Parametric Help for more information on customizing the Ribbon User Interface.
|
4. | Save the configuration in Creo Parametric so that changes to the ribbon user interface appear when a new session of Creo Parametric is started. |
• | Small icon—<iconname.ext> |
• | Large icon—<iconname_large.ext> |
• | <creo_loadpoint>\<version>\Common Files\text\resources |
• | <application_text_dir>\resource |
• | <application_text_dir>\<language_dir>/resource The location of the application text directory is specified in the Creo TOOLKIT registry file.
|
ProError ProCmdDesignate ( uiCmdCmdId cmd_id,
ProMenuItemLabel button_label,
ProMenuLineHelp one_line_help,
ProMenuDescription description,
ProFileName msg_file);
• | cmd_id—The command identifier. |
• | button_label—The message string that refers to the icon label. This label (stored in the message file) identifies the text seen when the button is displayed. If the command is not assigned an icon, the button_label string appears on the button by default. |
• | one_line_help—The one-line Help for the icon. This label (stored in the message file) identifies the help line seen when the mouse moves over the icon. |
• | description—The message appears in the Customize Ribbon tab in the Creo Parametric Options dialog and also when "Description" is clicked in Creo Parametric. |
• | msg_file—The message file name. All the labels including the one-line Help labels must be present in the message file. Note
This file must be in the directory <text_path>/text or <text_path>/text/<language>.
|
• | option_id—The option identifier. |
• | number_radio_group_items—Specifies the number of options in the radio group |
• | radio_group_items—Specifies an array of items in the radio group. |
• | radio_group_labels—Specifies the labels for the radio buttons. This label (stored in the message file) identifies the text seen when the button is displayed. If the command is not assigned an icon, the label string appears on the menu by default. |
• | one_line_helps—The one-line Help for the icon. This label (stored in the message file) identifies the help line seen when the mouse moves over the icon. |
• | radio_group_icons—Specifies an array of icon file names, including the extension. A valid format for the icon file is a standard .GIF, .JPG, or.PNG. PTC recommends using .PNG format. All icons in the Creo Parametric ribbon are either 16x16 (small) or 32x32 (large) size. The naming convention for the icons is as follows:
|
• | description—The message appears in the Customize Ribbon tab in the Creo Parametric Options dialog and also when "Description" is clicked in Creo Parametric. |
• | msg_file—The message file name. All the labels including the one-line Help labels must be present in the message file. Note
This file must be in the directory <text_path>/text or <text_path>/text/<language>.
|
• | cmd_id—The command identifier. |
• | allow—Specify as PRO_B_TRUE for the value of the command to be updated always. Specify it as PRO_B_FALSE, only when the command is accessible. |
• | Graphics window |
• | Model tree |
• | Some dialog boxes |
• | Any area where you can perform an object-action operation by selecting an item and then choosing a command to perform on the selected item. |
1. | Obtain the name of the existing popup menus to which you want to add a new menu using the trail file. |
2. | Register the Creo TOOLKIT notifications for creation and destruction of popup menus. |
3. | Create commands for the new popup menu items. |
4. | Implement access functions to provide visibility information for the items. |
5. | When the notification is called for the desired popup menu, add the custom buttons to the menu. |
6. | When the destroy notification is called, free the associated memory for the custom buttons. |
~ Close `rmb_popup` `PopupMenu`
~ Command `ProCmdEditProperties`
typedef uiCmdAccessState (*ProPopupmenuAccessFunction)
(uiCmdCmdId command,
ProAppData appdata,
ProSelection* sel_buffer);
• | menu_ID—Specifies the ID of the popup menu obtained from ProPopupmenuIdGet(). |
• | position—Specifies the position in the popup menu at which to add the menu button. Pass PRO_VALUE_UNUSED to add to the bottom of the menu. |
• | button_name—Specifies the name of the added button. The button name is placed in the trail file when the user selects the menu button. For more information on valid characters that you can use to specify the name, refer to the section Naming Convention for UI Components. |
• | button_label—Specifies the message that refers to the button label. This label identifies the text seen when the button is displayed.
To localize this text, obtain and pass a string from ProMessageToBuffer(). Note
The labels and the text added using the ProCmdDesignate() function duplicate existing messages that are previously added in the Creo database. To display the correct label and text message, you can use a prefix or a suffix with the message names that will
identify your Creo TOOLKIT application. You should avoid using generic names of Creo TOOLKIT buttons such as Point, Arc, Circle, Ellipse in the labels and text.
|
• | button_helptext—Specifies the help message associated with the button. This label acts as a keyword that identifies the help text in the message file. To localize this text, obtain and pass a string from ProMessageToBuffer(). |
• | cmd_ID—Specifies the command identifier for the action or option. |
• | access_status—Specifies the callback function used to determine the visibility status of the added button. |
• | appdata—Specifies the user application data. |
• | menu_ID—Specifies the ID of the popup menu obtained from ProPopupmenuIdGet(). |
• | position—Specifies the position in the menu at which to add the cascade button. Pass PRO_VALUE_UNUSED to add to the bottom of the menu. |
• | cascade_menu_name—Specifies the name of the cascade menu. The name is placed in the trail file when the user selects the menu button. For more information on valid characters that you can use to specify the name, refer to the section Naming Convention for UI Components. |
• | cascade_menu_label—Specifies the message that refers to the cascade menu label. This label identifies the text seen when the menu is displayed. To localize this text, obtain and pass a string from ProMessageToBuffer(). |
• | cascade_menu_helptext—Specifies the help message associated with the cascade menu. This label acts as a keyword that identifies the help text in the message file. To localize this text, obtain and pass a string from ProMessageToBuffer(). |
• | access_status—Specifies the callback function used to determine the visibility status of the added item. |
• | appdata—Specifies the user application data. |
• | The menu name used should be “ActionMenu”. |
• | The command access function should be configured to read the selection buffer using ProSelbufferSelectionsGet(). If the buffer is inactive or empty, the access function should make the menu item invisible. |
• | The current Creo Parametric startup directory |
• | The subdirectory text/menus under the directory named by the text_dir statement in the registry file |
text_dir .
• | .mnu—Files that describe complete menus |
• | .aux—Files that describe new buttons to be added to existing Creo Parametric menus |
• | The name must be unique through out Creo Parametric. |
• | The name must have no more than 30 characters, including the extension. |
• | Button name—If the button name as it appears on the Creo Parametric screen contains spaces, each space must be replaced by the character # in the menu file. If the button name is followed by
another name, separated by white space, the second name will be what is actually displayed. The first name is still used to refer to the button from your Creo TOOLKIT code. The second provides an optional translation of that button name.
|
• | One-line Help—This is a single line of text that explains what the menu button does. When you place the mouse pointer on the menu button, Creo Parametric displays the one-line Help text in the Message Window. |
• | Alternate Help—If this line is not blank (or does not start with the comment character “#”), it will be used in place of the one-line Help. This provides a translation of the Help message. |
Menu file "part.aux":
[Start of file on next line]
PART
<blank line>
<blank line>
Check#Part
Check the validity of the current part.
<blank line>
[End of file on previous line]
Menu file "part.aux":
[Start of file on next line]
PART
<blank line>
<blank line>
Check#Part DRC#Check
Check the validity of the current part.
Perform a DRC (Design Rule Check) on the part.
[End of file on previous line]
1. | Load the Creo Parametric menu into memory, using ProMenuFileRegister(). |
2. | Add the buttons in your menu file to the menu, using ProMenuAuxfileRegister(). |
3. | Define the actions of the new buttons, using ProMenubuttonActionSet(). |
• | ProMenuName menuname—The unique title of the menu that appears as the first word on the first line of the menu file and on the heading of the menu on the screen when you run Creo Parametric in English. This argument is case-insensitive. |
• | ProMenufileName filename—The name of the menu file, including the extension but not the directory. |
• | ProMenuName menuname—The title of the menu that contains the button. |
• | ProMenubuttonName button—The first name for the button in the menu file (not the second, which provides the translation), but with spaces instead of pound signs (#). This argument is case-insensitive. |
• | ProMenubuttonAction action—A pointer to the Creo TOOLKIT callback function to be called when the user selects this menu button. To pass a pointer to a function, supply the name of the function without the following parentheses. If your function does not precede the call to ProMenubuttonActionSet() in the same file, you must add a declaration of it to show the compiler that this is a function. |
• | The menu file you supply should end in .mnu, not .aux. (It has the same syntax, though.) |
• | You do not need to call ProMenuAuxfileRegister() because the whole menu is defined in a single menu file. |
• | You need to define an exit action for the menu, in addition to an action for each button on the menu. |
• | You can either specify the new menu in user_initialize() or you can set up the new menu locally before you use it. |
• | Nothing—The menu selection is ignored. This is useful if you want the user to take some definite action before leaving the current menu. |
• | Close the current menu—The menus unwind to the level of the menu selected and the selected command is entered. This is the usual way to leave a menu. |
1. | Load the Creo Parametric menu into memory, using ProMenuFileRegister(). |
2. | Define the actions of the new buttons, using the function ProMenubuttonActionSet(). |
3. | Define the exit action of the new menu, using the functions ProMenubuttonActionSet() and one of the exit action functions described in the following section. |
[Start of file on next line]
MYMENU
<blank line>
<blank line>
Partial#Check
Perform a partial check on the part.
<blank line>
Full#Check
Perform a full check on the part.
<blank line>
[End of file on previous line]
int menuId;
ProMenuFileRegister ("mymenu", "mymenu.mnu", &menuId);
ProMenubuttonActionSet ("mymenu", "Partial Check", ProCheckPart,
NULL, 0);
ProMenubuttonActionSet ("mymenu", "Full Check", ProCheckPart, NULL,
1);
ProMenubuttonActionSet ("mymenu", "Quit Checks",
(ProMenubuttonAction)ProMenuDelete, NULL, 0);
ProMenubuttonActionSet("mymenu", "mymenu",
(ProMenubuttonAction)ProMenuDelete, NULL, 0);
int menuId;
ProMenuFileRegister ("mymenu", "mymenu.mnu", &menuId);
ProMenubuttonActionSet ("mymenu", "Partial Check", ProCheckPart,
NULL, 0);
ProMenubuttonActionSet ("mymenu", "Full Check", ProCheckPart,
NULL, 1);
ProMenubuttonActionSet ("mymenu", "Quit Checks",
(ProMenubuttonAction)ProMenuDelete, NULL, 0);
ProMenubuttonActionSet ("mymenu", "mymenu",
(ProMenubuttonAction)ProMenuHold, NULL, 0);
1. | Display the menu, using ProMenuCreate(). |
2. | Make the menu active so the user can select from it, using ProMenuProcess(). |
1. | The code does not get executed until the menu is closed. |
2. | The code gets executed before any command that causes an exit from the menu. When the user closes a menu by selecting another command, that command is put into the input buffer and is not executed until control passes from your application back to Creo Parametric. |
1. | Specify which submenus to include in the compound menu, as follows:static char **compound_menu = {"MENU_1","MENU_2", "MENU_3", ""}; |
2. | Load the actions on the buttons. |
3. | Set the button visibility and accessibility. |
4. | Generate the compound menu, as follows:ProCompoundmenuCreate (compound_menu, n_submenus); |
5. | Get user input, as follows:ProMenuProcess (compound_menu[0], action); |
• | 0—The button becomes the first in the menu. |
• | 1—The button is inserted after the current first button. |
• | 2—The button is inserted after the current second button. |
• | –1—The button becomes the last button on the menu. |
• | PROMENUMODE_OPERATIONAL—The default mode. This mode is used in all the previous examples. On an operational menu, only one button is ever set (that is, displayed with a red background) while that command is in progress. |
• | PROMENUMODE_DATA—Each button remains set until you select it again. This is useful when the buttons do not represent commands, but, for example, a set of independently selectable options. |
• | The menu title |
• | The menu mode (either PROMENU_MODE_OPERATIONAL or PROMENUMODE_DATA) |
• | The menu title. |
• | The set indicator, which indicates which buttons are set. This argument can have either of the following values:
|
• | Done Select |
• | Quit Select |
• | List |
~ Command `<command name>`
$F2 @MAPKEY_LABELtest;
~ Command `ProCmdModelNew`
~ Activate `new` `OK`
~ Command `ProCmdModelNew`
~ Activate `new` `OK`
• | In asynchronous mode, macros are executed as soon as they are loaded with ProMacroLoad(). |
• | In synchronous mode, the mapkey or the macro strings are pushed onto a stack and are popped off and executed only when control returns to Creo Parametric from the Creo TOOLKIT program. Due to the last in, first out nature of the stack, macros that cannot be passed entirely in one ProMacroLoad() call should have the strings loaded in reverse order of desired execution. |
• | To execute a macro from within Creo TOOLKIT, call the function ProMacroExecute(). The function runs the Creo Parametric macro and returns the control to the Creo TOOLKIT application. It executes the macros previously loaded using the function ProMacroLoad(). The function works only in the synchronous mode. |
• | Do not call the function ProMacroExecute() during the following operations:
|
• | Clicking the OK button on the dialog box to complete the command operation. In this case, the dialog box may be displayed momentarily without
completing the command operation. Note
|
• | If some of the commands ask for an input to be entered from the keyboard (such as a part name), the macro continues execution
after you type the input and press ENTER. However, if you must select something with the mouse (such as selecting a sketching plane), the macro is interrupted and
ignores the remaining commands in the string. This allows the application to create object-independent macros for long sequences of repeating choices (as long as the user
does not have to select any geometry).
|
• | ProMacroLoad(macro wstring) to load the macro strings or the mapkey |
• | ProMacroExecute() to execute the macro |
• | To switch the wireframe display of model, use the macro:Command `ProCmdEnvWireframe` 1 |
• | To switch the shaded display of model, use the macro:~ Command `ProCmdEnvShaded` 1 |
• | You can switch the display for datum planes and datum axes using the following macros:
|
• | To repaint a model, use the macro:~ Command `ProCmdViewRepaint` |
• | To get the default model orientation, use the macro:~ Command `ProCmdNamedViewsGalSelect` `Default` |
• | To get the model information, use the macro:~ Command `ProCmdInfoModel` |
• | To create a hole feature, use the macro:~ Command `ProCmdHole` |
• | To extrude a feature, use the macro:~ Command `ProCmdFtExtrude` |
• | To create a datum plane, use the macro:~ Command `ProCmdDatumPlane` |