Open dwg file in Inventor 2022 fails

Open dwg file in Inventor 2022 fails

M.Zirk
Advocate Advocate
266 Views
2 Replies
Message 1 of 3

Open dwg file in Inventor 2022 fails

M.Zirk
Advocate
Advocate

Hello,

 

I try to open an 2018 Autocad file in Inventor 2022 by API.

 

Dim doc As Inventor.Document = InvApplication.Documents.Open(path, True)

 

I get the following exception:

 

Exception.png

 

Open the file in Inventor by hand is possible.

Open the file in a dwg application is possible.

I have double checked that the Documentname ( here I use the FullFileName) is valid.

 

What is going wrong?

 

Manfred

0 Likes
267 Views
2 Replies
Replies (2)
Message 2 of 3

yan.gauthier
Advocate
Advocate

You gotta use Inventor.Application.Documents.OpenWithOptions( FullDocumentName As String, Options As NameValueMap, [OpenVisible] As Boolean ) As Document

 

You have to create a NameValueMap. it should work if you do it like this:

 

 

Dim options As NameValueMap
Set options = ThisApplication.TransientObjects.CreateNameValueMap
options.Add("ImportNonInventorDWG", True)

Dim dwgDoc as Document
set dwgDoc = ThisApplication.Documents.OpenWithOptions(FullFileName, options, true)

 

 

Here is the list of NameValueMap from Inventor Doc

 

Name Type Valid Document Type Notes

DesignViewRepresentationStringPart, AssemblyThe name of the design view representation. If empty string is input then thhis will be ignored, and the setting in the FileOpenOptions will be applied.
PositionalRepresentationStringAssemblyThe name of the positional representation.
ModelStateStringPart,AssemblyTypically, the ModelState to use should be provided in the form of a FulDocumentName (first argument). But if this is provided separately, you should make sure that it does not conflict with the FullDocumentName argument by providing FullFileName as the first argument rather than a FullDocumentName.
DeferUpdatesBooleanDrawingIndicates if any pending updates for the drawing will be deferred when the drawing is opened.
FileVersionOptionValue from FileVersionEnumAllValid values for FileVersionEnum are kOpenOldVersion, kOpenCurrentVersion and kRestoreOldVersionToCurrent. If set to kOpenOldVersion, save will not be allowed on the opened document. kRestoreOldVersionToCurrent is valid only if no other versions are open and the current version is not checked out.
ImportNonInventorDWGBooleanImports the DWG file to an IDW if True, Opens it into Inventor DWG if FalseWhen opening non-Inventor DWG files, this method honors the application option to decide between open and import, unless an override is specified in the Options argument.
PasswordStringAll 
ExpressModeBehaviorStringAssemblyThe following values are valid for this setting: OpenExpress - Open the assembly in express mode. OpenFull - Open the assembly in full mode. OpenDefault - Open the assembly in the mode it was saved in.
SkipAllUnresolvedFilesBooleanAllIndicates to skip all unresolved files and continue to open the document.
DeferFlatPatternUpdateBooleanPartIndicates whether to defer the flat pattern compute or not when open a part with flat pattern in it.
0 Likes
Message 3 of 3

M.Zirk
Advocate
Advocate

Hello,

 

thank you for detailed reply and the recommendation.

I tried this but it failed also.

I found out what was wrong.

It was my errorhandler for unhandled exceptions in the addin.

After removing the FirstChance exeception handler no more exceptions occured.

 

Manfred

 

 

0 Likes