powerjobs_processor:jobprocessor:code_reference:cmdlets:open-document

Open-Document

Opens the specified document in a registered powerJobs Processor application

Open-Document -LocalFile <string> [-Application <string>] [-Options <HashTable/string>] [<CommonParameters>]

Type Name Description Optional
String LocalFile The path to the document that should be openedno
String Application Can be used to force opening the document with a specific application. Otherwise a valid provider will be automatically detectedyes
HashTable / String Options The application will open the document with this optionsyes

Bool: on success the cmdlet returns $true otherwise $false.
$result.Error ← The result has additionally an Error property which contains the Exception object
$result.Application ← Application is an implementation of IApplication
$result.Document ← Document is an implementation of IDocument

Depending on the application that opens the document, application specific default options will be used.
To check with which options the document was really opened, just take the $result.Document.OpenSettings which contains all the properties that where used for the opening.

These are the possible open Options for the default application:

Inventor / InventorServer

For Inventor and InventorServer the project file can be specified via @{'Project'='C:\temp\test.ipj'}.
Additionally all the options of the API method OpenWithOptions can be used, eg @{'Fast Open'=$true; 'LevelOfDetailRepresentation'='Master'}:

Type Name Description Default
string / System.IO.FileInfoProjectThe ProjectFile that Inventor uses to open the document. Possible: 'C:\somefile.ipj', [file]'C:\somefile.Ipj'Current Inventor Project
bool / stringVisible Specifies whether the document should be opened visible or invisible. Possible: $true,'False','TRUE'True
stringDesignViewRepresentation Only for assemblies and parts For assemblies the first DesignViewRepresentations of the document
stringPositionalRepresentation Only for assemblies
stringLevelOfDetailRepresentation Only for assemblies. Supported in Inventor versions 2021 and earlier Last saved LevelOfDetailRepresentation of the document, e.g. 'Master'
stringModelState Only for assemblies and parts. Supported in Inventor version 2022 The 'Master' model state
boolDeferUpdates Only for drawings
FileVersionEnum FileVersionOption
boolImportNonInventorDwg False
stringPassword
ExpressModeBehaviorExpressModeBehavior Only for assemblies
boolSkipAllUnresolvedFiles False
boolDeferFlatPatternUpdate Only for sheet metal parts False
boolFastOpen Only for drawings False

DWG TrueView

DWG TrueView has only the following options:

Type Name Description Default
bool / stringReadonly Specifies wether the document should be opened in readonly mode or not. Possible: $true,'False','TRUE'False

Opening an AutoCad dwg file

Open-Document -LocalFile 'C:\Vault\AutoCad\Test.dwg'

Opening an inventor drawing with FastOpen and correct project file

Open-Document -LocalFile 'C:\Vault\Inventor\PadLock\Pad Lock.idw' -Options @{'Project'='C:\Vault\Default.ipj';'FastOpen'=$true}

Forcing InventorServer to open a Inventor drawing

Open-Document -Application InventorServer -LocalFile 'C:\Vault\Inventor\Drawings\Footer.idw'

Validating if document was opened correctly

$result = Open-Document C:\Temp\Test.ipt
if(-not $result) {
 throw "Failed with error: ". $result.Error.Message
}

Using the open result

$result = Open-Document C:\Temp\Test.ipt

if($result.Application.Name -eq 'Inventor') {
  $result.Application.Instance.Visible=$true
  $result.Document.Instance ......
}