iLogic "Export face as" in DXF version 2000

iLogic "Export face as" in DXF version 2000

amarcoc
Advocate Advocate
666 Views
1 Reply
Message 1 of 2

iLogic "Export face as" in DXF version 2000

amarcoc
Advocate
Advocate

Hi.

 

I want to make sure output version of DXF is version 2000. Even if I change it manually, version always go to 2018 when using the macro I developed.

 

Please note that I don't want to export flat pattern. I want to export any selected face. I believe I cannot use DataIO, as it will only export flat pattern instead of any selected face.

 

Any idea on how I can make sure to export DXF 2000 version?

 

I am using Inventor Professional 2019 on a Windows 10 64 bits machine.

 

Thanks.

 

'check that this active document is a part file 
Imports System.Windows.Forms

If ThisApplication.ActiveDocument.DocumentType <> kPartDocumentObject Then MessageBox.Show("Apenas pode gravar um DXF em ficheiros *.ipt", "Erro!") Return End If revision = (iProperties.Value("Project", "Revision Number")) ofolder = ThisDoc.Path & "\PDF Automaticos\" If ThisApplication.GeneralOptions.UserName = "AMC" Then 'ofolder = ofolder & "\AMC\" End If FileExists = True FileName = ofolder & (iProperties.Value("Project", "Part Number")) & "_" & revision & ".dxf" Do While FileExists SaveAs = MessageBox.Show("Exportar face para o ficheiro '" & FileName & "'?", "Exportar DXF", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1) If Dir(FileName) <> "" Then My.Computer.FileSystem.DeleteFile(FileName) FileExists = True End If If SaveAs = vbNo Then Return Else ' User says continue FileExists = False End If Loop ThisApplication.ActiveView.Fit 'Criar Flat Pattern (se não existir), e alternar para Flat Pattern If ThisApplication.ActiveDocument.ComponentDefinition.Type = 150995200 ThisApplication.ActiveDocument.ComponentDefinition.Unfold() ThisApplication.ActiveDocument.ComponentDefinition.FlatPattern.Edit() End If Dim oDoc As PartDocument oDoc = ThisApplication.ActiveDocument 'add filename to memory for file save dialog Dim Cm As CommandManager Cm = ThisApplication.CommandManager Cm.PostPrivateEvent(PrivateEventTypeEnum.kFileNameEvent, FileName ) Dim oSelectSet As Selectset oSelectSet = oDoc.SelectSet oDoc.SelectSet.Clear() If Not System.IO.Directory.Exists(oFolder) Then System.IO.Directory.CreateDirectory(oFolder) End If 'SELECTION CODE Dim oFace As Face oFace = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kPartFaceFilter, "Seleccione uma face") If (oFace Is Nothing) Then Return Else Call oDoc.SelectSet.Select(oFace) End If ' EXPORT CODE 1 Dim oCtrlDef As ButtonDefinition oCtrlDef = ThisApplication.CommandManager.ControlDefinitions.Item("GeomToDXFCommand") Call oCtrlDef.Execute 'CLEAR selectset oDoc.SelectSet.Clear() If ThisApplication.ActiveDocument.ComponentDefinition.Type = 150995200 ThisApplication.ActiveDocument.ComponentDefinition.FlatPattern.ExitEdit() End If

 

0 Likes
667 Views
1 Reply
Reply (1)
Message 2 of 2

JamieVJohnson2
Collaborator
Collaborator

The only way to control version is to control the translator engine.  I have done this for a simple full file export, but not 'geometry' method.  More may chime in, and it may be only a matter of settings.  Here is the export method that controls the translator directly (VB.Net code):

Public Sub ExportACAD(settingsFile As String, isDWG As Boolean)
        Dim invApp As Inventor.Application = GetInventorApplication 'GetInventorApplication does similar to ThisApplication built in command for iLogic.
        ' Set a reference to the DWG translator add-in.
        Dim oDWGAddIn As TranslatorAddIn = Nothing
        'USE DWG OR DXF FIND "DESTNATION DXF=Yes or No" in ini file (text file)
        Dim ClassID As String = "{C24E3AC4-122E-11D5-8E91-0010B541CD80}"
        Dim ext As String = ".dxf"
        If isDWG Then
            ClassID = "{C24E3AC2-122E-11D5-8E91-0010B541CD80}" ' = DWG TRANSLATOR
            ext = ".dwg"
        End If
        Dim i As Long
        For i = 1 To invApp.ApplicationAddIns.Count()
            If invApp.ApplicationAddIns.Item(i).ClassIdString = ClassID Then
                oDWGAddIn = invApp.ApplicationAddIns.Item(i)
                Exit For
            End If
        Next
        If oDWGAddIn Is Nothing Then
            MsgBox("DWG add-in not found.", MsgBoxStyle.SystemModal)
            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 = invApp.TransientObjects.CreateNameValueMap()
        ' Create the name-value that specifies the ini file to use.
        Call oNameValueMap.Add("Export_Acad_IniFile", settingsFile)
        ' Create a translation context and define that we want to output to a file.
        Dim oContext As TranslationContext
        oContext = invApp.TransientObjects.CreateTranslationContext()
        oContext.Type = IOMechanismEnum.kFileBrowseIOMechanism
        ' Define the type of output by specifying the filename.
        Dim oOutputFile As DataMedium
        oOutputFile = invApp.TransientObjects.CreateDataMedium()
        oOutputFile.FileName = ACADFilePath & "\" & Name & ext
        ' Call the SaveCopyAs method of the add-in.
        If Not System.IO.File.Exists(oOutputFile.FileName) Then
            System.IO.Directory.CreateDirectory(System.IO.Path.GetDirectoryName(oOutputFile.FileName))
            oDWGAddIn.SaveCopyAs(docINV, oContext, oNameValueMap, oOutputFile)
        End If
    End Sub

You are going to need to read up in the Programmers API Help  to get more details on the translator (of choice, there are many - hence the guid) and its features (I posted to others on here about settings of the translator).  Here I used the configuration.ini files saved when you perform a manual export, that file contained all the options I wanted.

 

Jamie Johnson : Owner / Sisu Lissom, LLC https://sisulissom.com/
0 Likes