ActivateDocument
The ActivateDocument event notifies the client whenever a document is activated, i.e. when it becomes the top-level document displayed in the active window (for example when a document is opened or the user switches to another document window). _Pre fires before and _Post after the document is activated.
Editing a part in-place within an assembly does not activate the part; the assembly stays the active document (see [NewEditObject](<</code_reference/objects/inventor_event_mappings/application_events/neweditobject>)).
EventNames:
ActivateDocument_Pre
ActivateDocument_Post
Parameters
Type |
Name |
Description |
|---|---|---|
document |
Object that is being activated |
Remarks:
The active document is the top-level document that is being displayed in the active view. This means that in the case of editing a part inside an assembly, the active document will still be the assembly.
Examples:
ActivateDocument_Pre:
Register-InventorEvent -EventName ActivateDocument_Pre -Action 'PreActivateDocument'
function PreActivateDocument($document) {
#Write event code here
}
Accessing the active Inventor document from Vault event actions:
Register-InventorEvent -EventName ActivateDocument_Post -Action {
param($document)
$global:activeDocument = $document
}
Register-VaultEvent -EventName AddVaultFile_Post -Action {
param($file)
# Read information from iProperties stored in the Inventor document:
$category = $global:activeDocument._Category
$mass = $global:activeDocument._Mass
$density = $global:activeDocument._Density
$material = $global:activeDocument._Material
#Add-ERPObject -EntitySet 'Items' -Properties @{'Cat' = $category; 'Mass' = $mass; 'Den' = $density; 'Material' = $material ... }
}