Message 1 of 11
DWG Export INI

Not applicable
09-15-2004
03:31 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I have used this routine since R7 and got most of the original code directly
from Brian Ekins. Now in R8 something seem amiss. No matter what I do
Inventor wants to use the ini file in Docs & Settings\Local Settings\Temp.
I have tried running from both inside as a macro as well as externally in
VB. Anyone have similar results or comments?
Sub ExportToDwg()
On Error Resume Next
' Get the Inventor Application
Dim InvApp As Inventor.Application
Set InvApp = ThisApplication
' Make sure a drawing document is open.
If InvApp.ActiveDocumentType <> kDrawingDocumentObject Then
MsgBox "A drawing document must be active."
Exit Sub
End If
'Get the translator addins
Dim addIns As ApplicationAddIns
Set addIns = InvApp.ApplicationAddIns
'Find the DWG Translator add-in
Dim dwgAddIn As TranslatorAddIn
Dim dxfAddIn As TranslatorAddIn
Dim i As Long
For i = 1 To addIns.Count
If addIns(i).AddInType = kTranslationApplicationAddIn Then
If addIns(i).Description = "Autodesk Internal DWG Translator"
Then
Set dwgAddIn = addIns.Item(i)
End If
End If
Next i
'Activate AddIns
dwgAddIn.Activate
dxfAddIn.Activate
Dim map As NameValueMap
Dim context As TranslationContext
Dim trans As TransientObjects
Set trans = InvApp.TransientObjects
Set map = trans.CreateNameValueMap
Set context = trans.CreateTranslationContext
context.Type = kFileBrowseIOMechanism
Dim b As Boolean
Dim file As DataMedium
Set file = trans.CreateDataMedium
'Retrieve the export default ini files for dxf and dwg
Dim dwgIni As String
Err.Clear
b = dwgAddIn.HasSaveCopyAsOptions(file, context, map)
dwgIni = "C:\0\AlJon.ini"
CmDlg.FileName = ""
CmDlg.InitDir = "C:\Documents and Settings\tstrandberg\My
Documents\Clients\Aljon - Avatech\AlJon"
CmDlg.DialogTitle = "Avatech Inventor Utilities"
' Usage: Friendlyname1|*.ex1|Freindlyname2|*.ex2 etc.
CmDlg.Filter = "AutoCAD Files(*.dwg)|*.dwg"
CmDlg.ShowSave
file.FileName = CmDlg.FileName
If file.FileName = "" Then
MsgBox "Operation cancelled.", vbExclamation, "Avatech Inventor
Utilities"
Exit Sub
End If
map.Value("Export_Acad_IniFile") = dwgIni
dwgAddIn.SaveCopyAs InvApp.ActiveDocument, context, map, file
MsgBox "Finished Processing", vbInformation, "Avatech Inventor
Utilities"
End Sub
Tim Strandberg