使用Inventor iLogic自动将二维图转换成dwg格式的AutoCAD文件
使用Inventor iLogic自动将二维图转换成dwg格式的AutoCAD文件,代码如下:
- Dim oDoc As Document
- oDoc = ThisApplication.ActiveDocument
- Dim DWGAddIn As TranslatorAddIn
- DWGAddIn = ThisApplication.ApplicationAddIns.ItemById("{C24E3AC2-122E-11D5-8E91-0010B541CD80}")
- Dim oDocument As Document
- oDocument = ThisApplication.ActiveDocument
- Dim oContext As TranslationContext
- oContext = ThisApplication.TransientObjects.CreateTranslationContext
- oContext.Type = kFileBrowseIOMechanism
- ' Create a NameValueMap object
- Dim oOptions As NameValueMap
- oOptions = ThisApplication.TransientObjects.CreateNameValueMap
- ' Create a DataMedium object
- Dim oDataMediumDWG As DataMedium
- oDataMediumDWG = ThisApplication.TransientObjects.CreateDataMedium
- '---
- oPath = ThisDoc.Path
- oFileName = ThisDoc.FileName(False) 'without extension
- 'oRevNum = iProperties.Value("Project", "Revision Number")
- oDocument = ThisApplication.ActiveDocument
- 'oDataMedium = ThisApplication.TransientObjects.CreateDataMedium
- Dim strIniFile As String
- strIniFile = "C:\XX\XX\inventor2dwgconfig.ini"
- oOptions.Value("Export_Acad_IniFile") = strIniFile
- oFolder = "C:\Users\zgten\Desktop\PDF"
- oDataMediumDWG.FileName = oFolder + "" + oFileName & ".dwg"
- If System.IO.File.Exists(oDataMediumDWG.FileName) Then
- oChoice = MessageBox.Show(oDataMediumDWG.FileName & " Already Exists - Overwrite?", "Title", MessageBoxButtons.YesNo, MessageBoxIcon.Question)
- If oChoice = 7
- 'MessageBox.Show("exit", "Title")
- Return
- Else
- 'MessageBox.Show("Overwrite", "Title")
- End If
- End If
- 'Publish document.
- DWGAddIn.SaveCopyAs(oDocument, oContext, oOptions, oDataMediumDWG)
- Beep
- 'MessageBox.Show("Done!", "Title")