python二维图自动保存_Autodesk Inventor工程图自动保存PDF文件iLogic代码

这段代码展示了如何利用Autodesk Inventor的iLogic工具,自动将当前打开的工程图保存为PDF文件。通过设置保存选项,如颜色处理、线宽移除和分辨率,确保PDF质量。同时,代码会检查并创建目标保存路径,确保PDF能正确保存到指定的文件夹。
摘要由CSDN通过智能技术生成

代码形式: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-------

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值