Message 1 of 2

Not applicable
10-25-2021
02:58 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
hello, i have some code that exports all my drawings from an assembly in .dwg, with the part as there name but i need it to export with the part number. i've tried some variations but can't seem to figure it out.
Sub Main() Dim doc As AssemblyDocument = ThisDoc.Document For Each refDoc As Document In doc.AllReferencedDocuments Dim fileName As String = refDoc.FullFileName Dim ext As String = IO.Path.GetExtension(fileName) Dim inventorDwgFileName As String = fileName.Replace(ext, ".dwg") Dim autocadDwgFileName As String =(iProperties.Value("Project", "Part Number"), "-acad.dwg") If (IO.File.Exists(inventorDwgFileName) = False) Then MsgBox("Could not find inventor dwg: " & inventorDwgFileName) Continue For End If Dim dwgDoc As DrawingDocument = ThisApplication.Documents.Open(inventorDwgFileName) DWGOutUsingTranslatorAddIn(dwgDoc, autocadDwgFileName) dwgDoc.Close(True) Next End Sub Public Sub DWGOutUsingTranslatorAddIn(doc As DrawingDocument, newFileName As String) ' Set the path to your DWGOut.ini fiile here Dim dwgOutIniFile As String = "C:\Users\Monkey\Documents\Modularte\Cubo\DWGOut.ini" Dim oDWGAddIn As TranslatorAddIn = Nothing Dim i As Long For i = 1 To ThisApplication.ApplicationAddIns.Count If ThisApplication.ApplicationAddIns.Item(i).ClassIdString = "{C24E3AC2-122E-11D5-8E91-0010B541CD80}" Then oDWGAddIn = ThisApplication.ApplicationAddIns.Item(i) Exit For End If Next If oDWGAddIn Is Nothing Then MsgBox("DWG add-in not found.") Exit Sub End If If (IO.File.Exists(dwgOutIniFile) = False) Then MsgBox("Unable to find: " & dwgOutIniFile) Exit Sub End If If Not oDWGAddIn.Activated Then oDWGAddIn.Activate() End If Dim oNameValueMap As NameValueMap = ThisApplication.TransientObjects.CreateNameValueMap() oNameValueMap.Add("Export_Acad_IniFile", dwgOutIniFile) Dim oContext As TranslationContext = ThisApplication.TransientObjects.CreateTranslationContext() oContext.Type = IOMechanismEnum.kFileBrowseIOMechanism Dim oOutputFile As DataMedium = ThisApplication.TransientObjects.CreateDataMedium() oOutputFile.FileName = newFileName Call oDWGAddIn.SaveCopyAs(doc, oContext, oNameValueMap, oOutputFile) End Sub
Solved! Go to Solution.