CAD Forum - tips, tricks, discussion and utilities for AutoCAD, Inventor, Revit and other Autodesk products [www.cadforum.cz]
Cesky English Deutsch
Login/Register:
 Visitors: 5973 
Plex.Earth connects AutoCAD and Google Earth

CAD tip CAD tip # 9561:

Question CAD 
 %  platform  category 
Q - question

iLogic macro for exporting IDW/DWG Inventor drawings to DXF.

A - answer You can use the following iLogic macro to export an Inventor drawing to a DXF format file. The code is modified from the predefined user fragment available in Inventor version 2014 (and higher):

' Get the DXF translator Add-In.  
Dim DXFAddIn As TranslatorAddIn  
DXFAddIn = ThisApplication.ApplicationAddIns.ItemById("{C24E3AC4-122E-11D5-8E91-0010B541CD80}")  
'Set a reference to the active document (the document to be published).  
Dim oDocument As Document  
oDocument = ThisApplication.ActiveDocument  
Dim oContext As TranslationContext  
oContext = ThisApplication.TransientObjects.CreateTranslationContext  
oContext.Type = IOMechanismEnum.kFileBrowseIOMechanism  
' Create a NameValueMap object  
Dim oOptions As NameValueMap  
oOptions = ThisApplication.TransientObjects.CreateNameValueMap  
' Create a DataMedium object  
Dim oDataMedium As DataMedium  
oDataMedium = ThisApplication.TransientObjects.CreateDataMedium  
' Check whether the translator has 'SaveCopyAs' options  
If DXFAddIn.HasSaveCopyAsOptions(oDocument, oContext, oOptions) Then  
Dim strIniFile As String  
strIniFile = "C:\temp\dxfout.ini"  
' Create the name-value that specifies the ini file to use.  
oOptions.Value("Export_Acad_IniFile") = strIniFile  
End If  
'Set the destination file name  
oDataMedium.FileName = ThisDoc.PathAndFileName(False) & ".dxf" 'same folder, or uncomment:  
'oDataMedium.FileName = "C:\myDXFfolder\" & ThisDoc.FileName(False) & ".dxf" 'fixed folder  
'Publish document.  
DXFAddIn.SaveCopyAs(oDocument, oContext, oOptions, oDataMedium)  
'Launch the dxf file in whatever application Windows is set to open this document type with  
i = MessageBox.Show("Preview the DXF file?", "Title",MessageBoxButtons.YesNo,MessageBoxIcon.Question)  
If i = vbYes Then ThisDoc.Launch(oDataMedium.FileName)  

In version 2014 see:

Inv2014Inv2013Inv2012Inv2011
100% *  CAD 
22.11.2013    9652×  
Comments   Tell a friend

See also:
Tip 11542:How to reset the top browser node name back to the file name?
Tip 11244:Labels with incrementing numbers - assembly with numbered labels for laser cutting.
Tip 11211:Mass change of units in the whole Inventor assembly.
Tip 11111:Inventor drawing diplays flipped, mirrored (as from underside)
Tip 10889:How to get user's full domain name, phone No., department, e-mail...


Back   All CAD Tips All CAD tips&tricks

What are the .TFWX world files? « | » Copying parts including constraints in Inventor 2014.

Have we helped you? If you want to support the CAD Forum web service, consider buying one of our CAD applications, or our custom software development offerings, or donating via PayPal (see above). You may also add a link to your web - like this "fan" link: CAD Forum - tips, utilities, blocks for Autodesk products
CAD:    OS:    Categ: 
Text:  FAQ glossary   



Featuring:
Extend your AutoCAD LT productivity with our popular add-on
CADstudio LT Extension More info


Please use these tips at your own risk.
CAD Studio (Xanadu) is not responsible for possible problems that may occur as a result of using any of these tips.
TOPlist