蒹葭苍苍,白露为霜。
所谓伊人,在水一方。

Autodesk Inventor工程图自动保存PDF文件iLogic代码

代码形式:Inventor内置ilogic工具

兼容版本:Autodesk Inventor 2018

解决的问题:方便自动将工程图保存为PDF文件格式

具体代码如下:

 
  1: oPath = ThisDoc.Path
  2: oFileName = ThisDoc.FileName(False) 'without extension
  3: oRevNum = iProperties.Value("project", "revision number")
  4: oPDFAddIn = ThisApplication.ApplicationAddIns.ItemById _
  5: ("{0AC6FD96-2F4D-42CE-8BE0-8AEA580399E4}")
  6: oDocument = ThisApplication.ActiveDocument
  7: oContext = ThisApplication.TransientObjects.CreateTranslationContext
  8: oContext.Type = IOMechanismEnum.kFileBrowseIOMechanism
  9: oOptions = ThisApplication.TransientObjects.CreateNameValueMap
 10: oDataMedium = ThisApplication.TransientObjects.CreateDataMedium
 11:
 12: If oPDFAddIn.HasSaveCopyAsOptions(oDocument, oContext, oOptions) Then
 13: oOptions.Value("All_Color_AS_Black") = 0
 14: oOptions.Value("Remove_Line_Weights") = 1
 15: oOptions.Value("Vector_Resolution") = 400
 16: oOptions.Value("Sheet_Range") = Inventor.PrintRangeEnum.kPrintAllSheets
 17: 'oOptions.Value("Custom_Begin_Sheet") = 2'oOptions.Value("Custom_End_Sheet") = 4
 18: End If
 19:
 20:
 21: 'get PDF target folder path
 22: oFolder = "k:\dwg\pdf\"
 23:
 24:
 25: 'Check for the PDF folder and create it if it does not exist
 26: If Not System.IO.Directory.Exists(oFolder) Then
 27:     System.IO.Directory.CreateDirectory(oFolder)
 28: End If
 29:
 30:
 31: 'Set the PDF target file name
 32: oDataMedium.FileName = oFolder & "\" & oFileName & _
 33: " rev" & oRevNum & ".pdf"
 34:
 35:
 36: 'Publish document
 37: oPDFAddIn.SaveCopyAs(oDocument, oContext, oOptions, oDataMedium)
 38: '------end of iLogic-------
赞(3) 打赏
未经允许不得转载:酷居科技 » Autodesk Inventor工程图自动保存PDF文件iLogic代码

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址

锦瑟无端五十弦,一弦一柱思华年

酷居科技联系我们

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

微信扫一扫打赏