API "Export Face As DXF" in previous version?

API "Export Face As DXF" in previous version?

DRoam
Mentor Mentor
2,229 Views
6 Replies
Message 1 of 7

API "Export Face As DXF" in previous version?

DRoam
Mentor
Mentor

We have an iLogic script that automatically exports our dozens of plasma-cut parts to DXF, using this method:

 

Dim oCtrlDef As ButtonDefinition
oCtrlDef = ThisApplication.CommandManager.ControlDefinitions.Item("GeomToDXFCommand")

ThisApplication.CommandManager.PostPrivateEvent(PrivateEventTypeEnum.kFileNameEvent, oDXFFullFileName)

oCtrlDef.Execute

We just upgraded to Inventor 2020, and now this workflow has been broken because it exports them in 2018 DXF format, and our plasma software can't read it.

 

I did some searching for how to specify the file version, but no luck. The threads I found were old; hoping someone has come up with a way to do this. Any suggestions would be appreciated.

 

Note, this DOES need to export a particular face, not the entire part or a flat pattern.

0 Likes
Accepted solutions (1)
2,230 Views
6 Replies
Replies (6)
Message 2 of 7

DRoam
Mentor
Mentor

@MjDeck, do you know of any way to do this?

0 Likes
Message 3 of 7

Curtis_Waguespack
Consultant
Consultant
Accepted solution

Hi @DRoam 

 

I think if you manually right click a part face, and choose Export Face As, and then set the Options to use an older DXF version, then when you use this control definition it will use that last used version setting.

 

vvv.PNG

 

I hope this helps.
Best of luck to you in all of your Inventor pursuits,
Curtis
http://inventortrenches.blogspot.com

EESignature

Message 4 of 7

DRoam
Mentor
Mentor

Indeed it does! Curtis saves the day once again 😉 it's not ideal, but that does seem to work. Now I just have to get everyone (including myself) to remember to do that before using our export tool each time......

 

Since there doesn't seem to be a good way to do this properly via the API, I went ahead and created an enhancement request for it. Anyone interested can vote here: iLogic/API: Provide an API for exporting a face to DXF (with options) 

 

Thanks again for the tip, Curtis, will save us a lot of time in the meantime.

Message 5 of 7

Curtis_Waguespack
Consultant
Consultant

Hi @DRoam ,

 

Maybe do something like this and use a pre-configured *.ini file and then publish a throw away file to set the *.ini to be used, then delete that file, and then finally use the command manger lines to DXF out the selected face.

 

I hope this helps.
Best of luck to you in all of your Inventor pursuits,
Curtis
http://inventortrenches.blogspot.com

 

' 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\DXF_R12.ini" 'this is a pre-configed ini file

' Create the name-value that specifies the ini file to use.
oOptions.Value("Export_Acad_IniFile") = strIniFile
End If
'Set the destination file name
oDXFFullFileName = ThisDoc.PathAndFileName(False) & ".dxf"
oDataMedium.FileName = ThisDoc.PathAndFileName(False) & "_ThrowAway.dxf"

'Publish throw away document.
DXFAddIn.SaveCopyAs(oDocument, oContext, oOptions, oDataMedium)

'delete file
If System.IO.File.Exists( oDataMedium.FileName ) = True Then
System.IO.File.Delete( oDataMedium.FileName )
End If


Dim oCtrlDef As ButtonDefinition
oCtrlDef = ThisApplication.CommandManager.ControlDefinitions.Item("GeomToDXFCommand")

ThisApplication.CommandManager.PostPrivateEvent(PrivateEventTypeEnum.kFileNameEvent, oDXFFullFileName)

oCtrlDef.Execute

 

EESignature

0 Likes
Message 6 of 7

DRoam
Mentor
Mentor

Hi Curtis, thanks for your latest suggestion. I just now got around to testing it. I was optimistic, but for some reason it isn't working. It isn't setting the DXF export INI for subsequent exports using the GeomToDXFCommand command.

 

Upon further investigation, I discovered the dummy file created by the DXF translator appears to be corrupted or incomplete. When I try to open it, AutoCAD says:

 

Error in drawing header on line 1.
C:\Temp\SetExportSettings.dxf is not valid DXF file
Invalid or incomplete DXF input -- drawing discarded.

 

 This is different from the following message I get when trying to open a 2018 DXF in AutoCAD 2017:

Unknown value "AC1032" encountered in drawing version.
Invalid or incomplete DXF input -- drawing discarded.

So I don't think it's exporting it to a newer version -- I think it's corrupted or incomplete for some reason. And related to this (cause? effect?) the INI file is not being set.

 

Do you know why this might be?

 

In order to eliminate the INI file as the cause, I've attached the one we're using. Could you test it with the Translator export code and see if you get a valid file?

 

If the INI file isn't the cause, any ideas what else may cause the issues I'm seeing?

0 Likes
Message 7 of 7

DRoam
Mentor
Mentor

Ah, I think I found the problem. Apparently the translator export only works for drawings. When I run it on a drawing it works fine, and exports to R12 format as specified.

 

However, it doesn't appear to apply that INI file to the "GeomToDXFCommand" export 😕 so unfortunately I'm back to square one with having to remember (and have everyone else remember) to manually select the correct format, cancel out, THEN run our batch export.

 

This has already caused some issues and confusion for us. It's a frustrating regression and I'm surprised there's no good way to choose the DXF export version for a face. I guess I can create an idea for this but I don't know how high up the chain this one would go...

0 Likes