Open Assembly with view representation last saved

Open Assembly with view representation last saved

m.schrepfer
Advocate Advocate
131 Views
2 Replies
Message 1 of 3

Open Assembly with view representation last saved

m.schrepfer
Advocate
Advocate

Is there a way to open an assembly via programming (vb.net/VBA) with the last saved view representation?

In other words, the same behavior that I can configure in the application options.

Markus Schrepfer
0 Likes
132 Views
2 Replies
Replies (2)
Message 2 of 3

WCrihfield
Mentor
Mentor

Yes.  There are two main ways to open a document.  One is without specifying any options other than visibility.  The other option is to specify some options.  If you do not specify any options when opening a document by code, then the application options settings will be used.  If you specify options, then it will obey those specified options.

Below are links to the online help documentation for those two methods that are usually involved.

Documents.Open 

Documents.OpenWithOptions 

Example of opening an assembly with options specified:

Dim oDoc As Inventor.Document
Dim sFDN As String = "C:\Temp\MyAssembly.iam"
Dim oOptions As Inventor.NameValueMap = ThisApplication.TransientObjects.CreateNameValueMap()
oOptions.Value("SkipAllUnresolvedFiles") = True
oOptions.Value("DesignViewRepresentation") = "Default" 'name of DVR (view rep)
oOptions.Value("ExpressModeBehavior") = "OpenDefault"
oDoc = ThisApplication.Documents.OpenWithOptions(sFDN, oOptions, True)
'do something with that 'oDoc' variable now

If this solved your problem, or answered your question, please click ACCEPT SOLUTION .
Or, if this helped you, please click (LIKE or KUDOS) 👍.

 

Edit:  There is also a way to determine which DVR (DesignViewRepresentation) was the last one active in a specified file, using the FileManager.GetLastActiveDesignViewRepresentation method, which returns a String representing the name of that DVR.  Then that could be used when specifying the name of the one you want to be active when specifying options, and which DVR you want active when you open it.  That FileManager object is obtained directly from the application object ('ThisApplication' term in code) (Application.FileManager).

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

Message 3 of 3

m.schrepfer
Advocate
Advocate

Hi Wesley,

 

thanks a lot for this tipp. I will check this.

Markus Schrepfer
0 Likes