[Inventor] 使用Inventor iLogic自动将二维图转换成dwg格式的AutoCAD文件

JUMU实名认证 发表于 2022-05-05 22:01 | 显示全部楼层 | 复制链接分享      上一主题  翻页  下一主题
使用Inventor iLogic自动将二维图转换成dwg格式的AutoCAD文件,代码如下:
  1. Dim oDoc As Document
  2. oDoc = ThisApplication.ActiveDocument
  3. Dim DWGAddIn As TranslatorAddIn
  4. DWGAddIn = ThisApplication.ApplicationAddIns.ItemById("{C24E3AC2-122E-11D5-8E91-0010B541CD80}")
  5. Dim oDocument As Document
  6. oDocument = ThisApplication.ActiveDocument

  7. Dim oContext As TranslationContext
  8. oContext = ThisApplication.TransientObjects.CreateTranslationContext
  9. oContext.Type = kFileBrowseIOMechanism

  10. ' Create a NameValueMap object
  11. Dim oOptions As NameValueMap
  12. oOptions = ThisApplication.TransientObjects.CreateNameValueMap

  13. ' Create a DataMedium object
  14. Dim oDataMediumDWG As DataMedium
  15. oDataMediumDWG = ThisApplication.TransientObjects.CreateDataMedium
  16. '---
  17. oPath = ThisDoc.Path
  18. oFileName = ThisDoc.FileName(False) 'without extension
  19. 'oRevNum = iProperties.Value("Project", "Revision Number")
  20. oDocument = ThisApplication.ActiveDocument
  21. 'oDataMedium = ThisApplication.TransientObjects.CreateDataMedium

  22. Dim strIniFile As String
  23. strIniFile = "C:\XX\XX\inventor2dwgconfig.ini"
  24. oOptions.Value("Export_Acad_IniFile") = strIniFile

  25. oFolder = "C:\Users\zgten\Desktop\PDF"
  26. oDataMediumDWG.FileName = oFolder + "" + oFileName & ".dwg"
  27. If System.IO.File.Exists(oDataMediumDWG.FileName) Then
  28.         oChoice = MessageBox.Show(oDataMediumDWG.FileName & " Already Exists - Overwrite?", "Title", MessageBoxButtons.YesNo, MessageBoxIcon.Question)
  29.         If oChoice = 7
  30.                 'MessageBox.Show("exit", "Title")
  31.                 Return
  32.         Else
  33.                 'MessageBox.Show("Overwrite", "Title")
  34.         End If
  35. End If

  36. 'Publish document.
  37. DWGAddIn.SaveCopyAs(oDocument, oContext, oOptions, oDataMediumDWG)
  38. Beep
  39. 'MessageBox.Show("Done!", "Title")
复制代码

  距米网  

找到您想要的设计

工程师、学生在线交流学习平台
关注我们

手机版- 距米网 |苏公网安备32041102000587号

© 2017-2024 常州居居米智能技术有限公司 苏ICP备18040927号-1