FileInsertDialog
The FileInsertDialog event notifies the client whenever the user executes a command that selects a document to be inserted into another document, for example Place Component in an assembly, Derived Component in a part or Base View in a drawing. The event fires at the point where Inventor would display the standard Open dialog.
EventNames:
FileInsertDialog_Pre
Parameters
Type |
Name |
Description |
|---|---|---|
ResultParameters |
result |
Object used to supply the result of the operation. See below. |
document |
The object the file will be inserted into. For example, if the Place Component is invoked, this will be the assembly the component is being inserted into |
Result properties:
Type |
Name |
Description |
|---|---|---|
String |
FileName |
The file name to use. |
String |
DirectoryPath |
The directory where the file that should be inserted is in. |
String |
FullFileName |
The full file name of the file that will be used. Can be used to check that the set file name is correct. |
Remarks:
Three common commands are the Place Component command in assembly, the Derived Component command in part, and the Base View command in drawing.
By using this event and setting a fileName and directoryPath to the result variable, the user can replace the default Inventor behavior, normally used to replace the Inventor dialog with their own dialog.
To change the default behavior of Inventor you need to set both the FileName and DirectoryPath to the result variable, if none are set, the behavior will stay the same.
This event can be aborted by throwing an exception inside the action.
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:
FileInsertDialog_Pre:
Register-InventorEvent -EventName FileInsertDialog_Pre -Action 'PreFileInsertDialog'
function PreFileInsertDialog($result, $document) {
#Write event code here
$result.FileName = "12345.ipt"
$result.DirectoryPath = "C:\Vault"
$result.FullFileName # C:\Vault\12345.ipt
}