thanks for the video, it is helpful. can we relate the views scale and the sheet size together for example if I have many views in my sheet I would like to make the scale of views automatically changes according to my sheet size
When I create a project in Inventor, I always create subfolders with the names: Parts & Assemblies Standards Drawings I would like to be able to save the PDF files in the Drawings folder or even create another folder with the PDF name inside this workspace. What would the code look like for this alternative? Thanks
Hi Paulo, Thanks for your question. Curtis Waguespack is an expert in several Inventor topics and may have the answer for which you are looking. here is a shortcut to his article: inventortrenches.blogspot.com/2011/07/ilogic-to-save-pdf-files-to-new.html Regards, Dave
why do you not make the code like ActiveSheet.TitleBlock = TITLEBLOK iLoicVB-UpdateWhenDone = True ' Done and of Cause Spell it the same as the TITLEBLOCK name No need for all the if and else if
Hi Johan, You can use the drawing number as the name for the PDF. PDFName = iProperties.Value("Custom", "Drawing No:") ThisDoc.Document.SaveAs(PDFName & ".pdf" , True) I created the “Drawing No:” Custom parameter and use this in my Drawing Titleblock form. The PDF will save with the drawing number as its name. As far as auto run after a save. All you need to do is add the rule to the “After Save Document” Event Trigger. Thanks, Dave
Hi Johan, Try the code below. This code will save the PDF with the file name. '------start of iLogic------- 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 sSheetNumber As String '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 sSheetNumber = Right(oSheet.Name, sLen -lPos ) 'set PDF Options If oPDFAddIn.HasSaveCopyAsOptions(oDataMedium, oContext, oOptions) Then oOptions.Value("All_Color_AS_Black") = 1 oOptions.Value("Remove_Line_Weights") = 1 oOptions.Value("Vector_Resolution") = 400 oOptions.Value("Sheet_Range") = Inventor.PrintRangeEnum.kPrintSheetRange oOptions.Value("Custom_Begin_Sheet") = sSheetNumber oOptions.Value("Custom_End_Sheet") = sSheetNumber End If '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 & ".pdf" 'Publish document oPDFAddIn.SaveCopyAs(oDocument, oContext, oOptions, oDataMedium) Next '------end of iLogic-------
Thanks for excellent tutorial.
You are welcome!
thanks for the video, it is helpful. can we relate the views scale and the sheet size together for example if I have many views in my sheet I would like to make the scale of views automatically changes according to my sheet size
When I create a project in Inventor, I always create subfolders with the names:
Parts & Assemblies
Standards
Drawings
I would like to be able to save the PDF files in the Drawings folder or even create another folder with the PDF name inside this workspace.
What would the code look like for this alternative?
Thanks
Hi Paulo,
Thanks for your question. Curtis Waguespack is an expert in several Inventor topics and may have the answer for which you are looking. here is a shortcut to his article: inventortrenches.blogspot.com/2011/07/ilogic-to-save-pdf-files-to-new.html
Regards,
Dave
@@davebreiner2744 Thanks a lot.
WHERE DO YOU GET COMMANDS FOR UPDATE AND ZOOM RULE?
why do you not make the code like
ActiveSheet.TitleBlock = TITLEBLOK
iLoicVB-UpdateWhenDone = True
' Done and of Cause Spell it the same as the TITLEBLOCK name
No need for all the if and else if
The PDF print rule is nice, but it should have the drawing number instead of "Dave's PDF print"... Can it be? And run automatically when hitting save
Hi Johan,
You can use the drawing number as the name for the PDF.
PDFName = iProperties.Value("Custom", "Drawing No:")
ThisDoc.Document.SaveAs(PDFName & ".pdf" , True)
I created the “Drawing No:” Custom parameter and use this in my Drawing Titleblock form. The PDF will save with the drawing number as its name. As far as auto run after a save. All you need to do is add the rule to the “After Save Document” Event Trigger.
Thanks,
Dave
Hi Johan,
Try the code below. This code will save the PDF with the file name.
'------start of iLogic-------
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 sSheetNumber As String
'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
sSheetNumber = Right(oSheet.Name, sLen -lPos )
'set PDF Options
If oPDFAddIn.HasSaveCopyAsOptions(oDataMedium, oContext, oOptions) Then
oOptions.Value("All_Color_AS_Black") = 1
oOptions.Value("Remove_Line_Weights") = 1
oOptions.Value("Vector_Resolution") = 400
oOptions.Value("Sheet_Range") = Inventor.PrintRangeEnum.kPrintSheetRange
oOptions.Value("Custom_Begin_Sheet") = sSheetNumber
oOptions.Value("Custom_End_Sheet") = sSheetNumber
End If
'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 & ".pdf"
'Publish document
oPDFAddIn.SaveCopyAs(oDocument, oContext, oOptions, oDataMedium)
Next
'------end of iLogic-------