DocumentChange
The DocumentChange event notifies the client whenever an action causes any change to a document, supplying the reasons for the change. _Pre fires before the change is made and _Post after the change was made.
The event is not triggered for commands that do not change the document, such as measure and view commands.
Document changes happen very frequently, so the action should start with simple checks to see whether the change is relevant. If possible, use a more specific event instead (for example [ParameterChange](<</code_reference/objects/inventor_event_mappings/modeling_events/parameterchange>) for parameter changes).
EventNames:
DocumentChange_Pre
DocumentChange_Post
Parameters
Type |
Name |
Description |
|---|---|---|
reasonsForChange |
This argument indicates the type of change that occurred. The value is from the CommandTypesEnum list, which represents the different categories of changes that can be made. Typically this will be a single value from the list but it can represent multiple values that have been combined together so you need to use bitwise operations to check for a specific change. |
|
document |
The document the change is occurring within. |
Remarks:
This event can be aborted by throwing an exception inside the action, but only if it is registered with the _Pre suffix.
Throwing an OperationCanceledException aborts the operation without any message.
Throwing any other exception aborts the operation and displays the thrown exception in an Error Message Box.
Examples:
DocumentChange_Pre:
Register-InventorEvent -EventName DocumentChange_Pre -Action 'PreDocumentChange'
function PreDocumentChange($reasonsForChange, $document) {
#Write event code here
}
DocumentChange_Post:
Register-InventorEvent -EventName DocumentChange_Post -Action 'PostDocumentChange'
function PostDocumentChange($reasonsForChange, $document) {
#Write event code here
}