- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Dear Technical Guru's,
I am trying to adapt a PDF Save iLogic script so that individual sheets of the drawing save as a separate file. My company use a suffix in the part number that determines the material of the part to be manufactured, which can alter dependent upon specific requirements. Where a component can be made of multiple materials (with all other features remaining the same), we use iPart and the corresponding DWG file has multiple sheets with a different material/part number per sheet.
My question is this, is it possible to write a script where each sheet is exported as a separate PDF file using the base view of the iPart part number as the file name? Our current script is below.
Many thanks
Adam
Sub Main ()
FileName = ThisDoc.FileName(True) 'with extension
FileExtension = Right(FileName, 3)
If FileExtension = "dwg" Then
Save_As_PDF
Else
ErrorMessage
End If
End Sub
Sub Save_As_PDF
oPath = ThisDoc.Path
oFileName = ThisDoc.FileName(False) 'without extension
oPDFAddIn = ThisApplication.ApplicationAddIns.ItemById ("{0AC6FD96-2F4D-42CE-8BE0-8AEA580399E4}")
oDocument = ThisApplication.ActiveDocument
oContext = ThisApplication.TransientObjects.CreateTranslationContext
oContext.Type = IOMechanismEnum.kFileBrowseIOMechanism
oOptions = ThisApplication.TransientObjects.CreateNameValueMap
oDataMedium = ThisApplication.TransientObjects.CreateDataMedium
'Gets the Workspace Path
WorkspacePath= ThisDoc.WorkspacePath()
'Gets the Length of the WorkspacePath String
WorkspacePathLength = Len(WorkspacePath)
'Gets just the Path of the file
PathOnly = ThisDoc.Path
'Removes the Workspace Path from FullPath
DirectoryPath = Strings.Right(PathOnly, PathOnly.Length-WorkspacePathLength)
'Sets the Dirctory that the PDF should be saved in
PDFPath = "X:\Drawing Registers\AutoSave PDF Drawings" & DirectoryPath
PDFName = PDFPath & "\" & ThisDoc.FileName(False) & "_" & iProperties.Value("Summary", "Revision Number") & ".pdf"
'Set the PDF target file name
oDataMedium.FileName = PDFName
oOptions.Value("Sheet_Range") = Inventor.PrintRangeEnum.kPrintAllSheets
'Checks to see if that directory exists, if not, it is created
If(Not System.IO.Directory.Exists(PDFPath)) Then
System.IO.Directory.CreateDirectory(PDFPath)
End If
'Saves the PDF in the desired location
oPDFAddIn.SaveCopyAs(oDocument, oContext, oOptions, oDataMedium)
End Sub
Sub ErrorMessage
i = MessageBox.Show("This is not a drawing file. No PDF will be created.", "Create PDF", MessageBoxButtons.OK, MessageBoxIcon.Hand, MessageBoxDefaultButton.Button1)
End Sub
Solved! Go to Solution.