Hi everyone
I have iLogic which export multiple sheets from idw to PDF's. This iLogic works excellent but problem is that it export all sheets from idw. Sometimes I need only 10 sheets from 30. Have anyone idea how to change iLogic to get possibility to choose few sheets from bulk, for example sheet 1, 3, 5 and 20 to 30? Thanks a lot for help in advance, Greg.
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 'Define the drawing Dim oDrawing As DrawingDocument oDrawing = ThisDoc.Document Dim oSheet As Sheet Dim lPos As Long Dim rPos As Long Dim sLen As Long Dim sSheetName As String Dim iSheetNumber As Integer 'step through each drawing sheet For Each oSheet In oDrawing.Sheets 'find the seperator in the sheet name:number lPos = InStr(oSheet.Name, ":") 'find the number of characters in the sheet name sLen = Len(oSheet.Name) 'find the sheet name sSheetName = Left(oSheet.Name, lPos -1) 'find the sheet number iSheetNumber = Right(oSheet.Name, sLen -lPos) oOptions.Value("All_Color_AS_Black") = 0 oOptions.Value("Remove_Line_Weights") = 0 oOptions.Value("Vector_Resolution") = 400 oOptions.Value("Sheet_Range") = Inventor.PrintRangeEnum.kPrintCurrentSheet 'get PDF target folder path oFolder = Left(oPath, InStrRev(oPath, "\")) & "PDF" 'Check for the PDF folder and create it if it does not exist If Not System.IO.Directory.Exists(oFolder) Then System.IO.Directory.CreateDirectory(oFolder) End If 'Set the PDF target file name oDataMedium.FileName = oFolder & "\" & sSheetName & " " & iSheetNumber & ".pdf" oSheet.Activate 'Publish document oPDFAddIn.SaveCopyAs(oDocument, oContext, oOptions, oDataMedium) Next
Solved! Go to Solution.
Solved by WCrihfield. Go to Solution.
Solved by WCrihfield. Go to Solution.
@jolantavoigt9563 OK. That appears to be the original code that @Anonymous first posted at the start of this topic. That version of the code did not yet include specific sheet selection yet, so I assume that you simply want every sheet exported as a separate PDF, to the same location as the drawing file, and want to keep the sheet name & number as the name of each PDF. Are you sure you do not want the drawing's original file name included in the PDF file's name, before the sheet name & number? I will include a line that will include the drawing file's name in there, but keep that line commented out, just in case you may want to use that line instead of the line without it later. I hope this is what you were looking for.
Dim oDrawing As DrawingDocument = ThisDoc.Document
Dim sPath As String = ThisDoc.Path
Dim sName As String = ThisDoc.FileName(False)
Dim oPDFAddIn As TranslatorAddIn = ThisApplication.ApplicationAddIns.ItemById _
("{0AC6FD96-2F4D-42CE-8BE0-8AEA580399E4}")
Dim oContext As TranslationContext = ThisApplication.TransientObjects.CreateTranslationContext
oContext.Type = IOMechanismEnum.kFileBrowseIOMechanism
Dim oOptions As NameValueMap = ThisApplication.TransientObjects.CreateNameValueMap
Dim oDataMedium As DataMedium = ThisApplication.TransientObjects.CreateDataMedium
'these can be set once, before the loop, instead of each time within the loop
oOptions.Value("All_Color_AS_Black") = 0
oOptions.Value("Remove_Line_Weights") = 0
oOptions.Value("Vector_Resolution") = 400
oOptions.Value("Sheet_Range") = Inventor.PrintRangeEnum.kPrintCurrentSheet
Dim OriginalActiveSheet As Sheet = oDrawing.ActiveSheet
Dim sSheetName As String
Dim iSheetNumber As Integer
'step through each drawing sheet
For Each oSheet As Sheet In oDrawing.Sheets
oSheet.Activate
sSheetName = oSheet.Name.Split(":")(0)
iSheetNumber = oSheet.Name.Split(":")(1)
'Set the PDF target file name
oDataMedium.FileName = sPath & "\" & sSheetName & " " & iSheetNumber & ".pdf"
'oDataMedium.FileName = sPath & "\" & sName & " " & sSheetName & " " & iSheetNumber & ".pdf"
'Publish document
oPDFAddIn.SaveCopyAs(oDrawing, oContext, oOptions, oDataMedium)
Next
OriginalActiveSheet.Activate
If this solved your problem, or answered your question, please click ACCEPT SOLUTION .
Or, if this helped you, please click (LIKE or KUDOS) 👍.
Wesley Crihfield
(Not an Autodesk Employee)
Yes, I wanted to export all sheets, thank you for your assistance.
I'm very new to interacting in this forum, in any forum for that matter, I have always read thru many but never interacted. I have read your profile and we have a lot in common as far as CNC programming and Design engineering, I definitely would appreciate a mentor with your knowledge, is there such a thing in the Autodesk forum as adding someone to follow or add as favorites? Or maybe connect on LinkedIn?
Hi Guys,
I am sorry to ask, but I would like the exported pdf's to be named: filename-sheetname-sheetnumber.dpf
Right now the nameoutput is sheetname-sheetnumber.pdf
Is it possible?
🙂
Best regards Morten
Hi @thy_inventorAL62J. Yes, that is possible. In fact, that capability was already built into that last code I posted above, but that specific line of code, near the end of the code, was commented out (the line of code started with an apostrophe character). If you remove the apostrophe (') from the start of that line, and add an apostrophe to the start of the line of code just before that one (or just delete the line of code just before that one), that should make the code work the way you want it to. However, I slightly modified the code above to meet your needs and have posted the result within the attached text file.
Wesley Crihfield
(Not an Autodesk Employee)
Can't find what you're looking for? Ask the community or share your knowledge.