Message 1 of 5
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello
With some help (from this forum) the code to export a list of .idw files to dwg, dxf, pdf is working - but only on my machine!
(actually pdf will work on a colleagues machine - maybe it's the .ini file - will test tomorrow).
Below is a section of the code - if you edit the file path ( 4th line down) to a .idw can you export a dxf ( will need to create an .ini file & save here - %USERPROFILE%\Desktop\Batch Export\ACad2013.ini - by manually exporting to dxf first & saving the configuration)
Sub Main
Dim PathList As String
'enter a file path to a .idw
PathList = "C:\Vault Views\Drawings\025913-DRWG-06475.idw"
ThisDoc.Launch(PathList)
Dim doc As Document = ThisApplication.ActiveDocument
For Each oDoc In ThisApplication.Documents
If oDoc.DocumentType = DocumentTypeEnum.kDrawingDocumentObject Then
Call PrintDxf(oDoc)
End If
Next
Call doc.Close(True)
End Sub
Sub PrintDxf(oDoc As Document)
Dim oFolder As String = System.Environment.GetFolderPath(System.Environment.SpecialFolder.Desktop) & "\Batch Export\Dxf"
If Not System.IO.Directory.Exists(oFolder) Then
System.IO.Directory.CreateDirectory(oFolder)
End If
'strip out file extension
FileName1 = Left(oDoc.DisplayName, Len(oDoc.DisplayName))
FileName2 = Right(FileName1, 4)
If FileName2 = ".idw" Then ex = 4 Else ex =0
path_and_name = ThisDoc.PathAndFileName(False) ' without extension
oFileName = Left(FileName1,(Len(FileName1)-ex))
MessageBox.Show(oFileName, FileName1)
'Date: 26.09.2016
'Author: Reg Hasell - robbed off forum by AC
' Version 1.0
'
'It will Do a very basic check to see if the file already exists, (I did not want to slow the process down too much
'It will then Create a DWG file in the export directory.
'The major benefit is that it will also add the current Revision to the filename.
' Future development will also update the filename with a prompted date.
'Dim oDoc As Document
'oDoc = ThisApplication.ActiveDocument
Dim DWGAddIn As TranslatorAddIn
DWGAddIn = ThisApplication.ApplicationAddIns.ItemById("{C24E3AC2-122E-11D5-8E91-0010B541CD80}")
Dim oDocument As Document
oDocument = ThisApplication.ActiveDocument
oRevNum = oDocument.PropertySets.Item("Inventor User Defined Properties").Item("Issue").Value
Dim oContext As TranslationContext
oContext = ThisApplication.TransientObjects.CreateTranslationContext
oContext.Type = kFileBrowseIOMechanism
' Create a NameValueMap object
Dim oOptions As NameValueMap
oOptions = ThisApplication.TransientObjects.CreateNameValueMap
' Create a DataMedium object
Dim oDataMediumDWG As DataMedium
oDataMediumDWG = ThisApplication.TransientObjects.CreateDataMedium
oDataMedium = ThisApplication.TransientObjects.CreateDataMedium
Dim strIniFile As String
'FROM INVENTOR EXPORT A DXF & SAVE THE .ini file
strIniFile = "%USERPROFILE%\Desktop\Batch Export\ACad2013.ini"
oOptions.Value("Export_Acad_IniFile") = strIniFile
oFolder = (System.Environment.GetFolderPath(System.Environment.SpecialFolder.Desktop) & "\Batch Export\dxf\")& dName
oDataMediumDWG.FileName =oFolder + oFileName &"."& oRevNum &".dxf"
MessageBox.Show(oFolder, "oFolder")
MessageBox.Show(oFileName, "oFileName")
MessageBox.Show(oRevNum , "oRevNum ")
'''--- Publish document.
DWGAddIn.SaveCopyAs(oDocument, oContext, oOptions, oDataMediumDWG)
End Sub
Error being seen on a different machine is:
Regards
Andrew
Solved! Go to Solution.