Open-Document

Opens the specified document in a registered powerJobs Processor Applications.

Syntax

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

Parameters

Type

Name

Description

Optional

String

LocalFile

The path to the document that should be opened

no

String

Application

Can be used to force opening the document with a specific application. Otherwise a valid provider will be automatically detected

yes

HashTable / String

Options

The application will open the document with this options

yes

Return type

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

Remarks

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.FileInfo

Project

The ProjectFile that Inventor uses to open the document. Possible: 'C:\somefile.ipj', [file]'C:\somefile.Ipj'

Current Inventor Project

bool / string

Visible

Specifies whether the document should be opened visible or invisible. Possible: $true,'False','TRUE'

True

string

DesignViewRepresentation

Only for assemblies and parts

For assemblies the first DesignViewRepresentations of the document

string

PositionalRepresentation

Only for assemblies

string

LevelOfDetailRepresentation

Only for assemblies. Supported in Inventor versions 2021 and earlier

Last saved LevelOfDetailRepresentation of the document, e.g. ‘Master’

string

ModelState

Only for assemblies and parts. Supported in Inventor version 2022

The ‘Master’ model state

bool

DeferUpdates

Only for drawings

FileVersionEnum

FileVersionOption

bool

ImportNonInventorDwg

False

string

Password

ExpressModeBehavior

ExpressModeBehavior

Only for assemblies

bool

SkipAllUnresolvedFiles

False

bool

DeferFlatPatternUpdate

Only for sheet metal parts

False

bool

FastOpen

Only for drawings

False

DWG TrueView

DWG TrueView has only the following options:

Type

Name

Description

Default

bool / string

Readonly

Specifies wether the document should be opened in readonly mode or not. Possible: $true,'False','TRUE'

False

Examples

Opening an AutoCad dwg file

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

Opening an inventor drawing with FastOpen and correct project file

1
2
3
4
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

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

Validating if document was opened correctly

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

Using the open result

1
2
3
4
5
6
7
$result = Open-Document C:\Temp\Test.ipt

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