HI, thanks. So I managed to create the dxf.
I just have the problem that the dxf is empty.
I have tried to safe the export dxf.ini from when I do it manually (which works) but without luck.
If ThisApplication.ActiveDocumentType <> DocumentTypeEnum.kDrawingDocumentObject Then
MsgBox("This Rule " & iLogicVb.RuleName & " only works on Drawing Documents. Exiting.",vbOKOnly + vbCritical, "WRONG DOCUMENT TYPE")
Return
End If
Dim oDDoc As DrawingDocument = ThisDrawing.Document
Dim oSheet As Sheet = oDDoc.ActiveSheet
Dim oTempDDoc As DrawingDocument = ThisApplication.Documents.Add(DocumentTypeEnum.kDrawingDocumentObject,,False)
Dim oTempSheet As Sheet = oSheet.CopyTo(oTempDDoc)
For Each oTSheet As Sheet In oTempDDoc.Sheets
If oTSheet IsNot oTempSheet Then
oTSheet.Delete
End If
Next
Dim oDXF_AddIn As TranslatorAddIn
For Each oAddIn As ApplicationAddIn In ThisApplication.ApplicationAddIns
If oAddIn.DisplayName = "Translator: PDF" Then
oDXF_AddIn = oAddIn
End If
Next
Dim oTO As TransientObjects = ThisApplication.TransientObjects
Dim oContext As TranslationContext = oTO.CreateTranslationContext
oContext.Type = IOMechanismEnum.kFileBrowseIOMechanism
Dim oOptions As NameValueMap = oTO.CreateNameValueMap
Dim oDataMedium As DataMedium = oTO.CreateDataMedium
Dim oPath As String = "H:"
Dim oFName As String = IO.Path.GetFileNameWithoutExtension(oDDoc.FullFileName)
oDataMedium.FileName = oPath & "\" & oFName & "-DXF.dxf"
If oDXF_AddIn.HasSaveCopyAsOptions(oTempDDoc, oContext, oOptions) Then
oOptions.Value("Export_Acad_IniFile") = "C:\Users\Public\Documents\Autodesk\Inventor 2021\Design Data\DWG-DXF\exportdxf.ini"
End If
'Check to see if the PDF already exists, if it does, ask if you want to over write existing file or not.
If System.IO.File.Exists(oDataMedium.FileName) = True Then
oAnswer = MsgBox("A PDF file with this name already exists." & vbCrLf &
"Do you want to over write it with this new one?",vbYesNo + vbQuestion + vbDefaultButton2, "PDF ALREADY EXISTS")
If oAnswer = vbNo Then Return
End If
'Publish DXF
oDXF_AddIn.SaveCopyAs(oTempDDoc, oContext, oOptions, oDataMedium)
oTempDDoc.Close(True)
And this here is the content of the dxf.ini
[EXPORT SELECT OPTIONS]
AUTOCAD VERSION=AutoCAD 2007
CREATE AUTOCAD MECHANICAL=No
USE TRANSMITTAL=Yes
USE CUSTOMIZE=No
CUSTOMIZE FILE=Design Data\DWG-DXF\FlatPattern.xml
CREATE LAYER GROUP=No
PARTS ONLY=No
[EXPORT PROPERTIES]
SELECTED PROPERTIES=
[EXPORT DESTINATION]
SPACE=Model
SCALING=Geometry
MAPPING=MapsBest
MODEL GEOMETRY ONLY=No
EXPLODE DIMENSIONS=No
SYMBOLS ARE BLOCKED=Yes
AUTOCAD TEMPLATE=
DESTINATION DXF=Yes
[EXPORT LINE TYPE & LINE SCALE]
LINE TYPE FILE=COMPATIBILITY\Support\invANSI.lin
Continuous=Continuous;0.
Dashed=DASHED;0.
Dashed Space=DASHED_SPACE;0.
Long Dash Dotted=LONG_DASH_DOTTED;0.
Long Dash Double Dot=LONG_DASH_DOUBLE_DOT;0.
Long Dash Triple Dot=LONG_DASH_TRIPLE_DOT;0.
Dotted=DOTTED;0.
Chain=CHAIN;0.
Double Dash Chain=DOUBLE_DASH_CHAIN;0.
Dash Double Dot=DASH_DOUBLE_DOT;0.
Dash Dot=DASH_DOT;0.
Double Dash Dot=DOUBLE_DASH_DOT;0.
Double Dash Double Dot=DOUBLE_DASH_DOUBLE_DOT;0.
Dash Triple Dot=DASH_TRIPLE_DOT;0.
Double Dash Triple Dot=DOUBLE_DASH_TRIPLE_DOT;0.
Cheers