Exporting multi page DWG using Sheet Name for exported files
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
My team current creates part drawings with a part drawing & cutfile on different sheets in the same drawing file.
The current drawing template currently renames the sheets based on the first part placed on the drawing, and adds the "_CutFile" suffix if the view is a flat pattern.
I have been using the code below to export all open drawings to PDF & DWG in their own folder which works great, but each multi page DWG gets exported with the naming convension "DrawingName_SheetName"
Example
A103-6-1001-TestPart.idw exports to
A103-6-1001-TestPart_A103-6-1001-TestPart.dwg
A103-6-1001-TestPart_A103-6-1001-TestPart_Cutfile.dwg
I would like to remove eveything before the underscore, and just have each file export with the sheet name only.
I have an idea about how to achieve this with the Sheet.Name property but unsure how to add it into the export rule below
Any help would be appreciated
Sub main() For Each document As Document In ThisApplication.Documents.VisibleDocuments If (Document.DocumentType <> DocumentTypeEnum.kDrawingDocumentObject) Then Logger.Info("Skipped file: " + Document.FullFileName) Continue For End If Dim fileName As String = System.IO.Path.GetFileNameWithoutExtension(Document.FullFileName) Dim fileInfo As New System.IO.FileInfo(Document.FullFileName) Dim subFolder = fileInfo.Directory.CreateSubdirectory(fileName) Dim pdfFullFileName = System.IO.Path.Combine(subFolder.FullName, fileName + ".pdf") CreatePdf(pdfFullFileName) Dim dwgFullFileName = System.IO.Path.Combine(subFolder.FullName, fileName + ".dwg") CreateDwg(dwgFullFileName) Logger.Info("Created pdf and dwg from file: " + Document.FullFileName) Next End Sub Private Sub CreatePdf(fullFileName As String) ' Get the PDF add-in Dim pdfAddIn As ApplicationAddIn pdfAddIn = ThisApplication.ApplicationAddIns.ItemById("{0AC6FD96-2F4D-42CE-8BE0-8AEA580399E4}") ' Create the translation context Dim context As TranslationContext context = ThisApplication.TransientObjects.CreateTranslationContext context.Type = IOMechanismEnum.kFileBrowseIOMechanism ' Create the name-value map for options Dim options As NameValueMap options = ThisApplication.TransientObjects.CreateNameValueMap ' Set PDF export options options.Value("Remove_Line_Weights") = 1 options.Value("All_Color_AS_Black") = 0 options.Value("Vector_Resolution") = 400 options.Value("Sheet_Range") = Inventor.PrintRangeEnum.kPrintAllSheets ' Create the data medium for PDF Dim dataMediumPDF As DataMedium dataMediumPDF = ThisApplication.TransientObjects.CreateDataMedium dataMediumPDF.FileName = fullFileName ' Export the document to PDF If pdfAddIn.HasSaveCopyAsOptions(ThisDoc.Document, context, options) Then pdfAddIn.SaveCopyAs(ThisDoc.Document, context, options, dataMediumPDF) End If End Sub Private Sub CreateDwg(fullFileName As String) ' Get the DWG add-in Dim dwgAddIn As ApplicationAddIn = ThisApplication.ApplicationAddIns.ItemById("{C24E3AC2-122E-11D5-8E91-0010B541CD80}") ' Create the translation context Dim context As TranslationContext context = ThisApplication.TransientObjects.CreateTranslationContext context.Type = IOMechanismEnum.kFileBrowseIOMechanism ' Reset the options for DWG export Dim options = ThisApplication.TransientObjects.CreateNameValueMap ' Set DWG export options using an INI file Dim workspacePath As String = ThisApplication.DesignProjectManager.ActiveDesignProject.WorkspacePath Dim strIniFile As String = System.IO.Path.Combine(workspacePath, "zInventorStuff\iLogic\DWGExport.ini") ' Create the name-value that specifies the ini file to use. options.Value("Export_Acad_IniFile") = strIniFile ' Create the data medium for DWG Dim dataMediumDWG As DataMedium dataMediumDWG = ThisApplication.TransientObjects.CreateDataMedium dataMediumDWG.FileName = fullFileName ' Export the document to DWG If dwgAddIn.HasSaveCopyAsOptions(ThisDoc.Document, context, options) Then dwgAddIn.SaveCopyAs(ThisDoc.Document, context, options, dataMediumDWG) End If End Sub