DXF Export Inventor 2017

DXF Export Inventor 2017

Anonymous
Not applicable
7,114 Views
4 Replies
Message 1 of 5

DXF Export Inventor 2017

Anonymous
Not applicable

Hi everybody

I am trying to use the snippet "Export DXF from IDW" using iLogic with Inventor 2017

I have tested in different drawing files and I always get the message:

 

The parameter is incorrect. (Exception from HRESULT: 0x80070057 (E_INVALIDARG))

 

System.ArgumentException: The parameter is incorrect. (Exception from HRESULT: 0x80070057 (E_INVALIDARG))
at System.RuntimeType.ForwardCallToInvokeMember(String memberName, BindingFlags flags, Object target, Int32[] aWrapperTypes, MessageData& msgData)
at Inventor.TranslatorAddIn.SaveCopyAs(Object SourceObject, TranslationContext Context, NameValueMap Options, DataMedium TargetData)
at LmiRuleScript.Main()
at Autodesk.iLogic.Exec.AppDomExec.ExecRuleInAssembly(Assembly assem)
at iLogic.RuleEvalContainer.ExecRuleEval(String execRule)

 

I also get the same message when exporting to DWG.

 

Any known issue/change with the Inventor version?

 

0 Likes
Accepted solutions (1)
7,115 Views
4 Replies
Replies (4)
Message 2 of 5

S_May
Mentor
Mentor

Hallo @Anonymous,

 

bitte teste mal den Code, ich habe aktuell in 2017 nicht getestet, ich weis nicht genau von wann der code ist Smiley Embarassed!

 

 
' 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"
'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)

MFG

 

 

Sascha May

0 Likes
Message 3 of 5

Anonymous
Not applicable
Accepted solution

The problem was the location and permission to create the *.ini file, now is working! @S_May thanks anyway

Message 4 of 5

meck
Collaborator
Collaborator

Hi Dcasas50,

                        

I am getting they same error message on the Call DXFAddIn.SaveCopyAs(oDocument, oContext, oOptions, oDataMedium) line of code.

I have tried saving the ini file to everywhere possible on my computer and nothing changes.

 

Could you please tell me what steps you did to fix the problem.

 

Thanks

Mike

Mike Eck
Master Drafter/ CAD Programmer
Using Inventor 2018
0 Likes
Message 5 of 5

Anonymous
Not applicable

Hello Mike

Attached is the code I'm using, for me the problem was solved only specifying the correct oPath , hope it can be useful for you.

 

SyntaxEditor Code Snippet

Sub ExportPDF_and_Autocad()
   ' Set a reference to the DWG translator add-in.
    Dim oDWGAddIn As TranslatorAddIn
    Dim Count As Double
    Dim x As Long
    Dim i As Long
    Dim oPath As String
    Dim oName As String
        
    oPath = ThisDoc.WorkspacePath()+"\2D Drawings\"
    
    oName= "GA"
    
    For i = 1 To ThisApplication.ApplicationAddIns.count
    If ThisApplication.ApplicationAddIns.Item(i).ClassIdString = "{C24E3AC2-122E-11D5-8E91-0010B541CD80}" Then
        oDWGAddIn = ThisApplication.ApplicationAddIns.Item(i)
        Exit For
    End If
    Next
   
    If oDWGAddIn Is Nothing Then
        'MsgBox ("The DWG add-in could not be found.")
        Exit Sub
    End If
   
   ' Check to make sure the add-in is activated.
    If Not oDWGAddIn.Activated Then
        oDWGAddIn.Activate
    End If
   
   ' Create a name-value map to supply information
    ' to the translator.
    Dim oNameValueMap As NameValueMap
    oNameValueMap = ThisApplication.TransientObjects.CreateNameValueMap
   
    Dim strIniFile As String = oPath + "DWGOut.ini"
   
    ' Create the name-value that specifies
    ' the ini file to use.
    Call oNameValueMap.Add("Export_Acad_IniFile", strIniFile)
  
   ' Create a translation context and define
    ' that we want to output to a file.
    Dim oContext As TranslationContext
    oContext = ThisApplication.TransientObjects.CreateTranslationContext
    oContext.Type = kFileBrowseIOMechanism
   
   ' Define the type of output by
    ' specifying the filename.
    Dim oOutputFile As DataMedium
    oOutputFile = ThisApplication.TransientObjects.CreateDataMedium
    oOutputFile.FileName = oPath+oName+".dwg"
    
    ' Call the SaveCopyAs method of the add-in.
       Try
    
    Call oDWGAddIn.SaveCopyAs(ThisApplication.ActiveDocument,oContext,oNameValueMap,oOutputFile)
    
    Catch ex1 As Exception
'        MessageBox.Show(ex1.Message, "Error")

    End Try
    
        
End Sub

 

  Regards

 

0 Likes