Well, I have such function as below:
Public Function ImportDXF(filePath As String) As Document
Dim DXFAddIn As TranslatorAddIn
Set DXFAddIn = ThisApplication.ApplicationAddIns.ItemById("{C24E3AC2-122E-11D5-8E91-0010B541CD80}")
Dim oContext As TranslationContext
Set oContext = ThisApplication.TransientObjects.CreateTranslationContext
oContext.Type = kFileBrowseIOMechanism
Dim oOptions As NameValueMap
Set oOptions = ThisApplication.TransientObjects.CreateNameValueMap
oOptions.Value("Import_Acad_IniFile") = dwgImportConfig
Dim oDataMedium As DataMedium
Set oDataMedium = ThisApplication.TransientObjects.CreateDataMedium
oDataMedium.MediumType = kFileNameMedium
oDataMedium.filename = filePath
Dim oDoc As Document
Call DXFAddIn.Open(oDataMedium, oContext, oOptions, oDoc)
oDoc.Close (True)
Set ImportDXF = ThisApplication.ActiveDocument
End Function
When it comes to line 21 that tries to open a file, a message box appears with description such as:
You cannot open DWG file. If the file os opened in AutoCAD or another application, close it and try again.
The file I try to open is not opened by other software, of course.
After closing the msgbox, run-time error appears: "Method 'Open' of object 'TranslatorAddin' failed"
When I try to make import manually it works, while using the same .ini file.
Does anyone have some idea what's wrong?
The same function (with appropriate .ini file) works well for dwg files.
It looks like some bug in the translator, but maybe I miss something?
Best regards,
Maciej Wojda