Message 1 of 14
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I'm looking for an iLogic Rule that will export my Inventor Model to a .dwg file.
Solved! Go to Solution.
I'm looking for an iLogic Rule that will export my Inventor Model to a .dwg file.
Solved! Go to Solution.
First create a drawing,
then look in the Inventor Help, API help, at the examples you will find this:
Export to DWG API Sample
Public Sub PublishDWG() ' Get the DWG translator Add-In. Dim DWGAddIn As TranslatorAddIn Set DWGAddIn = ThisApplication.ApplicationAddIns.ItemById("{C24E3AC2-122E-11D5-8E91-0010B541CD80}") 'Set a reference to the active document (the document to be published). Dim oDocument As Document Set oDocument = ThisApplication.ActiveDocument Dim oContext As TranslationContext Set oContext = ThisApplication.TransientObjects.CreateTranslationContext oContext.Type = kFileBrowseIOMechanism ' Create a NameValueMap object Dim oOptions As NameValueMap Set oOptions = ThisApplication.TransientObjects.CreateNameValueMap ' Create a DataMedium object Dim oDataMedium As DataMedium Set oDataMedium = ThisApplication.TransientObjects.CreateDataMedium ' Check whether the translator has 'SaveCopyAs' options If DWGAddIn.HasSaveCopyAsOptions(oDocument, oContext, oOptions) Then Dim strIniFile As String strIniFile = "C:\tempDWGOut.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 = "c:\tempdwgout.dwg" 'Publish document. Call DWGAddIn.SaveCopyAs(oDocument, oContext, oOptions, oDataMedium) End Sub |
Sorry I think I have you confused, I am looking for an iLogic rule that will export my .iam file (Inventor Model) to AutoCad 3d. And when i tried running your code it came back with an error.
So you want to save it out as a .step file so you can load it in autocad 3d?
Try the below iLogic code which is converted from above VBA code. Before executing code, specify the path of "tempDWGOut.ini" file.
Public Sub Main() ' Get the DWG translator Add-In. Dim DWGAddIn As TranslatorAddIn DWGAddIn = ThisApplication.ApplicationAddIns.ItemById("{C24E3AC2-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 = 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 DWGAddIn.HasSaveCopyAsOptions(oDocument, oContext, oOptions) Then Dim strIniFile As String strIniFile = "C:\tempDWGOut.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 = "c:\tempdwgout.dwg" 'Publish document. Call DWGAddIn.SaveCopyAs(oDocument, oContext, oOptions, oDataMedium) End Sub
Please feel free to contact if there is any queries.
If solves problem, click on "Accept as solution" / give a "Kudo".
Thanks and regards,
No my firm still uses an AutoCad 3d file with the .dwg file extension for layout work.
THAT WORKED!! Thanks
Hi
I stumbled across this thread while looking to do exactly the same thing, as I export my solid models all the time, but never really thought of automating it.
I ran the code and discovered that there is no way to create an ".ini" file for a model export.
After reviewing the code a little more, I discovered that it is exactly the same method as exporting a drawing file. (.idw) I tested my existing code, and it works perfectly.
I am now using the same code that I use to export my drawings, and it uses the same '.ini' file for both '.iam' and '.idw'
Hi
Okay, as promised, I found it.
I modified it slightly, as the Version did not work, and changed the version as follows:
If oDocument.DocumentType = kPartDocumentObject Or oDocument.DocumentType = kAssemblyDocumentObject Then 'Acad 2010 = 29 'Acad 2013 = 31 'Acad 2018 = 32 oOptions.Value("DwgVersion") = 31 oOptions.Value("Solid") = True oOptions.Value("Surface") = False oOptions.Value("Sketch") = False End If
It all works now.
Hi
The code for converting the inventor assembly to autocad is working but i would like to convert it into 2007 version
may i know the Equivalent value for the oOptions.Value("DwgVersion") for the autocad 2007 version
Thanks & Regards
K.Shunmugasundaram
Hi
Apologies for the delay.
here is a list of the values:
SyntaxEditor Code Snippet
If oDocument.DocumentType = kPartDocumentObject Or oDocument.DocumentType = kAssemblyDocumentObject Then 'Acad 2000 = 23 (AC1015) 'Acad 2004 = 25 (AC1018) 'Acad 2007 = 27 (AC1021) 'Acad 2010 = 29 (AC1024) 'Acad 2013 = 31 (AC1027) 'Acad 2018 = 32 (AC1032) oOptions.Value("DwgVersion") = 31 oOptions.Value("Solid") = True oOptions.Value("Surface") = False oOptions.Value("Sketch") = False End If
Is it possible to export only that views which are is visible in the border ? (via VBA)
Many times i have auxiliary views, cross-sections etc. outside the border and i do not want to export it to dwg.
Hi
Sorry mate, I have no idea. I used to do it manually in AutoCAD, but then binned that idea very quickly.
There might be a method to move all the geometry outside the drawing border to a new/frozen layer? (That's what I did manually, it was way too tedious, and really painful to manage with design changes.)