Event-driven Programming: Notifications
Notifications allow your Creo TOOLKIT application to detect certain types of events in Creo Parametric and provide that your own function is called before or after each such event. Creo Parametric notifies your Creo TOOLKIT application of these events.
Using Notify
Functions Introduced:
The function ProNotificationSet() sets up a notification by specifying the type of event and the pointer to the callback function. The event is specified as a value of the enumerated type ProNotifyType. The argument for the callback function has the type ProFunction; for consistency, each callback function returns a ProError status, even in cases where the status is ignored by Creo Parametric. The callback functions have different arguments, so each callback type has its own typedef that defines its arguments and their types. When calling ProNotificationSet(), you must cast the callback function pointer to ProFunction.
Note
•  If you call ProNotificationSet() more than once with the same event type, the existing callback is overwritten with the one supplied in the later call.
•  When notifications are set in Creo TOOLKIT applications, every time an event is triggered, notification messages are added to the trail files. From Creo Parametric 2.0 M210 onward, a new environment variable PROTK_LOG_DISABLE enables you to disable this behavior. When set to true, the notifications messages are not added to the trail files.
To cancel a notification, call ProNotificationUnset().
Notification Types
The notification events in Creo Parametric fall into the following classes:
File Management Events
Notifications to all of the file management operations in Creo Parametric, such as save, retrieve, copy, rename and so on.
Note
From Creo Parametric 3.0 onward, some callback functions and events for notifications have been deprecated, and will be obsolete in future releases. Refer to the header files ProMdl.h and ProNotify.h for more information.
The possible file management notifications fall into the following subclasses:
Pre-file Management Events
Your callback function is called before the file management event. It is called only for models that are the explicit objects of the file management operation. For example, it is not called when a part is saved as a result of saving a parent assembly.
If the Creo Parametric user initiated the event, the callback is called before the prompt asking the user for the name of the Creo Parametric models on which to act.
The callback function can optionally write output arguments that determine the Creo Parametric models on which the event will operate. In this case, Creo Parametric will not prompt the user.
The callback function can, by returning an error status, cancel the file management event altogether.
Pre-file Management Events
Event type
Callback typedef
Include file
PRO_MODEL_FILE_OPEN_OK
ProModelFileOpenOKAction
ProNotify.h
PRO_MODEL_SAVE_PRE
ProModelSavePreAction
ProMdl.h
PRO_MODEL_COPY_PRE
ProModelCopyPreAction
ProMdl.h
PRO_MODEL_RENAME_PRE
ProModelRenamePreAction
ProMdl.h
PRO_MODEL_RETRIEVE_PRE
ProModelRetrievePreAction
ProMdl.h
PRO_MDL_ERASE_PRE
ProMdlErasePreAction
ProMdl.h
PRO_MODEL_PURGE_PRE
ProModelPurgePreAction
ProMdl.h
PRO_MDL_DELETE_PRE
ProMdlDeletePreAction
ProMdl.h
PRO_MODEL_CREATE_PRE
ProModelCreatePreAction
ProMdl.h
PRO_MODEL_START
ProModelStartAction
ProMdl.h
PRO_CHECKIN_UI_PRE
ProCheckinUIPreAction
ProNotify.h
PRO_MODEL_SAVE_PRE_ALL
ProModelSavePreAllAction
ProMdl.h
The callback function ProModelRetrievePreAction gets called only when you click File  Open button in the Creo Parametric user interface. Retrieval of the models by dragging or by double clicking in browser window results in the not triggering the call back. Once set, this notification blocks the Creo Parametric's standard File  Open event. Hence, you must substitute the blocked event with your own event through this function.
Pre-All File Management Events
Your callback function is called before all file management events on models, even if those models were not explicitly specified by the user. For example, if you save an assembly, the callback function is also called for any modified parts that will be saved as a result of that action.
Event type
Callback typedef
Include file
PRO_MODEL_SAVE_PRE_ALL
ProModelSavePreAllAction
ProMdl.h
Post-file Management Events
Your callback function is called after the file management operation, and is given input arguments that show which models were the subject of the operation. Like a pre-file management callback, it is called only for models that are the explicit objects of the file management operation.
Post-file Management Events
Event type
Callback typedef
Include file
PRO_MODEL_SAVE_POST
ProModelSavePostAction
ProMdl.h
PRO_MODEL_COPY_POST
ProModelCopyPostAction
ProMdl.h
PRO_MODEL_RENAME_POST
ProModelRenamePostAction
ProMdl.h
PRO_MODEL_ERASE_POST
ProModelErasePostAction
ProMdl.h
PRO_MODEL_RETRIEVE_POST
ProModelRetrievePostAction
ProMdl.h
PRO_MODEL_PURGE_POST
ProModelPurgePostAction
ProMdl.h
PRO_MODEL_DELETE_POST
ProModelDeletePostAction
ProMdl.h
PRO_MODEL_CREATE_POST
ProModelCreatePostAction
ProMdl.h
PRO_UDF_LIB_COMPLETE_POST
ProUdfLibraryCompletePostAction
ProUdf.h
Post All File Management Events
Your callback function is called for all file management events on models, even if those models were not explicitly specified by the user. For example, if you save an assembly, the callback function is also called for any modified parts that are saved as a result of that action.
Post All File Management Events
Event type
Callback typedef
Include file
PRO_MODEL_SAVE_POST_ALL
ProModelSavePostAllAction
ProMdl.h
PRO_MODEL_COPY_POST_ALL
ProModelCopyPostAllAction
ProMdl.h
PRO_MODEL_ERASE_POST_ALL
ProModelErasePostAllAction
ProMdl.h
PRO_MODEL_RETRIEVE_POST_ALL
ProModelRetrievePostAllAction
ProMdl.h
PRO_MODEL_DELETE_POST_ALL
ProModelDeletePostAllAction
ProMdl.h
File Management Failure Events
Your callback function is called after a file management operation that failed. The function is called with arguments that show the type of file management operation that failed, the models it was operating on, and the type of error encountered (in the form of a ProError value).
Note
From Creo Parametric 3.0 onward, some callback functions and events for notifications have been deprecated. Refer to the header files ProMdl.h and ProNotify.h for more information.
File Management Failed Events
Event type
Callback typedef
Include file
PRO_MODEL_DBMS_FAILURE
ProModelDbmsFailureAction
ProMdl.h
PRO_MDL_CREATE_CANCEL
ProMdlCreateCancelAction
ProNotify.h
Model and Feature Modification Events
Notifications that signal a change to the content of the model. They often include both pre- and post-notifications of change events and include operations on features, solids, parameters and dimensions. See the section Notes on Regeneration Events for more information.
Use the notification types PRO_FEATURE_REROUTE_PRE and PRO_FEATURE_REROUTE_POST to trap the command Feature Reroute in parts or assemblies. Use notification types PRO_FEATURE_REPLACE_PRE and PRO_FEATURE_REPLACE_POST to trap replacement of assembly components performed in assembly mode with the command Component, Adv Utils, Replace.
The notification types PRO_ASMCOMP_ACTIVATE_PRE and PRO_ASMCOMP_ACTIVATE_POST are called before and after an assembly component is activated within the context of an assembly in Creo Parametric using the right mouse button Activate. The notification types provide the path to the currently active component, allowing applications to understand the context of an action in the assembly.
Notes on Regeneration Events
Notifications which trigger before or after feature regeneration should be used carefully, because your callback function is being called while the regeneration of a solid is in progress. This section describes some of the important information you should keep in mind when using notification for model events.
At the start of model regeneration, Creo Parametric discards all data structures that describe geometry, although the geometry items themselves are retained (to preserve the integer identifiers). This means that although you can still traverse the features (using ProSolidFeatVisit()) and the geometry items in a feature (using ProFeatureGeomitemVisit()), geometry items belonging to features not yet regenerated will have no corresponding OHandles. Therefore, functions such as ProSurfaceInit() and ProEdgeInit() will not work. If you analyze the geometry of the features already regenerated, you will see it as unmodified by the features still to be regenerated.
It is dangerous to attempt modifications to the model or file management operations during a regeneration notification function.
Model Modification Events
Event type
Callback typedef
Include file
PRO_DIM_MODIFY_VALUE_PRE
ProDimModifyValuePreAction
ProDimension.h
PRO_FEATURE_CREATE_PRE
ProFeatureCreatePreAction
ProFeature.h
PRO_FEATURE_CREATE_POST
ProFeatureCreatePostAction
ProFeature.h
PRO_FEATURE_COPY_POST
ProFeatureCopyPostAction
ProFeature.h
PRO_FEATURE_DELETE_PRE
ProFeatureDeletePreAction
ProFeature.h
PRO_FEATURE_DELETE_POST
ProFeatureDeletePostAction
ProFeature.h
PRO_FEATURE_SUPPRESS_PRE
ProFeatureSuppressPreAction
ProFeature.h
PRO_FEATURE_SUPPRESS_POST
ProFeatureSuppressPostAction
ProFeature.h
PRO_FEATURE_REDEFINE_PRE
ProFeatureRedefinePreAction
ProFeature.h
PRO_FEATURE_REDEFINE_POST
ProFeatureRedefinePostAction
ProFeature.h
PRO_FEATURE_REGEN_PRE
ProFeatureRegenPreAction
ProFeature.h
PRO_FEATURE_REGEN_POST
ProFeatureRegenPostAction
ProFeature.h
PRO_FEATURE_REGEN_FAILURE
ProFeatureRegenFailureAction
ProFeature.h
PRO_FEATURE_NEEDS_REGEN_GET
ProFeatureNeedsRegenGet
ProFeature.h
PRO_FEATURE_REROUTE_PRE
ProFeatureReroutePreAction
ProFeature.h
PRO_FEATURE_REROUTE_POST
ProFeatureReroutePostAction
ProFeature.h
PRO_FEATURE_REPLACE_PRE
ProFeatureReplacePreAction
ProFeature.h
PRO_FEATURE_REPLACE_POST
ProFeatureReplacePostAction
ProFeature.h
PRO_GROUP_UNGROUP_PRE
ProGroupUngroupPreAction
ProGroup.h
PRO_GROUP_UNGROUP_POST
ProGroupUngroupPostAction
ProGroup.h
PRO_PARAM_MODIFY_W_UNITS_PRE
ProParameterCreateWithUnitsPreAction
ProParameter.h
PRO_PARAM_CREATE_POST
ProParameterCreatePostAction
ProParameter.h
PRO_PARAM_MODIFY_W_UNITS_PRE
ProParameterModifyWithUnitsPreAction
ProParameter.h
PRO_PARAM_MODIFY_W_UNITS_POST
ProParameterModifyWithUnitsPostAction
ProParameter.h
PRO_PARAM_DELETE_PRE
ProParameterDeletePreAction
ProParameter.h
PRO_PARAM_DELETE_W_UNITS_POST
ProParameterDeleteWithUnitsPostAction
ProParameter.h
PRO_SOLID_REGEN_PRE
ProSolidRegeneratePreAction
ProSolid.h
PRO_SOLID_REGEN_POST
ProSolidRegeneratePostAction
ProSolid.h
PRO_SOLID_UNIT_CONVERT_PRE
ProSolidUnitConvertPreAction
ProNotify.h
PRO_SOLID_UNIT_CONVERT_POST
ProSolidUnitConvertPostAction
ProNotify.h
PRO_SOLID_PRINC_SYS_
UNITS_RENAMED_POST
ProSolidPrincSysUnitsRenamedPostAction
ProNotify.h
PRO_DWGTABLE_ROW_
DELETE_PRE
ProDwgtableRowDeletePreAction
ProNotify.h
PRO_DWGTABLE_ROW_DELETE
_POST
ProDwgtableRowDeletePostAction
ProNotify.h
PRO_DWGTABLE_DELETE_PRE
ProDwgtableDeletePreAction
ProNotify.h
PRO_DWGTABLE_DELETE_POST
ProDwgtableDeletePostAction
ProNotify.h
Context Change Events
Notifications called after events that change details in the current Creo Parametric context. They allow your application to leverage the details of these changes as needed.
Session Context Events
Event type
Callback typedef
Include file
PRO_DIRECTORY_CHANGE_POST
ProDirectoryChangePostAction
ProNotify.h
PRO_WINDOW_CHANGE_POST
ProWindowChangePostAction
ProNotify.h
PRO_POPUPMENU_CREATE_POST
ProPopupmenuCreatePostAction
ProPopupmenu.h
PRO_POPUPMENU_DESTROY_PRE
ProPopupmenuDestroyPreAction
ProPopupmenu.h
PRO_WINDOW_VACATE_PRE
ProWindowVacatePreAction
ProWindows.h
PRO_WINDOW_OCCUPY_POST
ProWindowOccupyPostAction
ProWindows.h
PRO_WINDOW_OCCUPY_MODEL_POST
ProWindowOccupyModelPostAction
ProWindows.h
PRO_GLOBAL_INTERF_CALC_POST
ProGlobalInterfCalcPostAction
ProNotify.h
PRO_ASMCOMP_ACTIVATE_PRE
ProAsmcompActivatePreAction
ProNotify.h
PRO_ASMCOMP_ACTIVATE_POST
ProAsmcompActivatePostAction
ProNotify.h
Graphics Events
Notifications before and after the repainting of the current Creo Parametric window. This enables you to overlay your own graphics over the window and ensure that they get refreshed when the Creo Parametric window is repainted, for any reason.
Note
These notifications will be called many times; for this reason, your callback routine should be as optimized as possible to avoid performance penalties. For other techniques that may be used to draw graphics, which will repaint with the Creo Parametric window, refer to the section on Display Lists. Refer to the User Interface: Basic Graphics section for details.
Graphics Events
Event type
Callback typedef
Include file
PRO_MDL_DISPLAY_PRE
ProMdlDisplayPreAction
ProMdl.h
PRO_MDL_DISPLAY_POST
ProMdlDisplayPostAction
ProMdl.h
NC Output Events
Notification of the output from Creo NC of an operation CL data file, or an Creo NC sequence CL data file. This enables you to perform your own post-processing on these files. The callback functions are called with arguments that provide the name of the file created.
NC Output Events
Event type
Callback typedef
Include file
PRO_NCSEQ_CL_POST
ProNcseqClPostAction
ProNotify.h
PRO_OPER_CL_POST
ProMfgoperClPostAction
ProNotify.h
CL Command Events
Notifications that give you the ability to create auxiliary NC sequences with programmatically created CL commands.
CL Command Events
Event type
Callback typedef
Include file
PRO_NCL_COMMAND_EXPAND
ProClCommandExpandAction
ProClCmd.h
PRO_NCL_COMMAND_GET_LOC
ProClCommandGetLocAction
ProClCmd.h
Mold Layout Events
Notifications that are invoked before entering a corresponding Mold Layout dialog.
Mold Layout UI Events
Event type
Callback typedef
Include file
PRO_RMDT_CREATE_IMM_PRE
ProRmdtCreateImmPreAction
ProRmdt.h
PRO_RMDT_BOUND_BOX_PRE
ProRmdtBoundBoxPreAction
ProRmdt.h
PRO_RMDT_CAV_LAYOUT_PRE
ProRmdtCavLayoutPreAction
ProRmdt.h
PRO_RMDT_CREATE_WP_PRE
ProRmdtCreateWpPreAction
ProRmdt.h
PRO_RMDT_MATERIAL_PRE
ProRmdtMaterialPreAction
ProRmdt.h
PRO_RMDT_MBASE_SELECT_PRE
ProRmdtMBaseSelectPreAction
ProRmdt.h
Selection Events
Notifications are invoked when there is a change in selection. Creo TOOLKIT application checks how the selection was changed by comparing the current selection buffer with the previous selection that was cached.
Selection Buffer Events
Event type
Callback typedef
Include file
PRO_SELBUFFER_CHANGE_POST
ProSelbufferChangePostAction
ProSelbuffer.h
Weld Events
Notifications that give you the ability to customize the results generated by Creo Parametric when gathering info for weld operations.
Weld Events
Event type
Callback typedef
Include file
PRO_DRAWING_WELD_SYMPATH_GET
ProDrawingWeldSympathGetAction
ProNotify.h
PRO_DRAWING_WELD_GROUPIDS_GET
ProDrawingWeldGroupidsGetAction
ProNotify.h
PRO_DRAWING_WELD_SYMTEXT_GET
ProDrawingWeldSymtextGetAction
ProNotify.h