去评论
距米网-精简版

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

JUMU
2022/05/05 22:01:55
使用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")