Export pack and go DXF with ilogic

Export pack and go DXF with ilogic

Codered741
Contributor Contributor
1,204 Views
3 Replies
Message 1 of 4

Export pack and go DXF with ilogic

Codered741
Contributor
Contributor

I am trying to export all sheets of a drawing as DXF's, in a pack and go ZIP file for easy management.  I have the ini config file which works with the DWG export, but I cannot get the output to save as a .zip file.  

 

Here is what I am working with. 

 

' Get the DXF translator Add-In.
Dim DXFAddIn As TranslatorAddIn = ThisApplication.ApplicationAddIns.ItemById("{C24E3AC4-122E-11D5-8E91-0010B541CD80}")
  
 'Set a reference to the active document (the document to be published).
Dim oDocument As Document = ThisApplication.ActiveDocument

Dim oContext As TranslationContext = ThisApplication.TransientObjects.CreateTranslationContext
oContext.Type = kFileBrowseIOMechanism

' Create a NameValueMap object
Dim oOptions As NameValueMap = ThisApplication.TransientObjects.CreateNameValueMap

' Create a DataMedium object
Dim oDataMedium As DataMedium = ThisApplication.TransientObjects.CreateDataMedium

' Check whether the translator has 'SaveCopyAs' options
If DXFAddIn.HasSaveCopyAsOptions(oDocument, oContext, oOptions) Then

Dim strIniFile As String
strIniFile = "C:\dxf_export.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:\temp\dxf.zip"

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

 This code exports all the sheets of a drawing if I change the file name output under "oDataMedium.FileName" to a .dxf extension, and the ini file to USE TRANSMITTAL=No.   

 

I had to change the file extension of the ini file so i could upload it. 

0 Likes
1,205 Views
3 Replies
Replies (3)
Message 2 of 4

MechMachineMan
Advisor
Advisor

It looks like there is some other resources out there to guide you through working with zipping files to have it export then add to the zip manually.

 

https://www.dotnetperls.com/zipfile-vbnet


--------------------------------------
Did you find this reply helpful ? If so please use the 'Accept as Solution' or 'Like' button below.

Justin K
Inventor 2018.2.3, Build 227 | Excel 2013+ VBA
ERP/CAD Communication | Custom Scripting
Machine Design | Process Optimization


iLogic/Inventor API: Autodesk Online Help | API Shortcut In Google Chrome | iLogic API Documentation
Vb.Net/VBA Programming: MSDN | Stackoverflow | Excel Object Model
Inventor API/VBA/Vb.Net Learning Resources: Forum Thread

Sample Solutions:Debugging in iLogic ( and Batch PDF Export Sample ) | API HasSaveCopyAs Issues |
BOM Export & Column Reorder | Reorient Skewed Part | Add Internal Profile Dogbones |
Run iLogic From VBA | Batch File Renaming| Continuous Pick/Rename Objects

Local Help: %PUBLIC%\Documents\Autodesk\Inventor 2018\Local Help

Ideas: Dockable/Customizable Property Browser | Section Line API/Thread Feature in Assembly/PartsList API Static Cells | Fourth BOM Type
0 Likes
Message 3 of 4

sajith_subramanian
Autodesk Support
Autodesk Support

Hi @Codered741,

 

In the ini file when I set "USE TRANSMITTAL=No", it outputs as a dxf. But when i set to  "USE TRANSMITTAL=Yes" , it creates a zip file. 

 

I used the code in the API help to test:

 

Public Sub PublishDXF()
    ' Get the DXF translator Add-In.
    Dim DXFAddIn As TranslatorAddIn
    Set 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
    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 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 = "c:\temp\dxfout.dxf"   ' no need to change this extension to zip

    'Publish document.
    Call DXFAddIn.SaveCopyAs(oDocument, oContext, oOptions, oDataMedium)
End Sub

 

Have you tried doing the same? Do you get different results?

 

Do let me know if this works for you.

 

Regards,

Sajith


Sajith Subramanian
Autodesk Developer Network
Message 4 of 4

aronmatheus
Advocate
Advocate
oPath = ThisDoc.Path
oFolder = oPath
oFileName = ThisDoc.FileName(False)
' Get the DXF translator Add-In.
Dim DXFAddIn As TranslatorAddIn = ThisApplication.ApplicationAddIns.ItemById("{C24E3AC4-122E-11D5-8E91-0010B541CD80}")
  
 'Set a reference to the active document (the document to be published).
Dim oDocument As Document = ThisApplication.ActiveDocument

Dim oContext As TranslationContext = ThisApplication.TransientObjects.CreateTranslationContext
oContext.Type = kFileBrowseIOMechanism

' Create a NameValueMap object
Dim oOptions As NameValueMap = ThisApplication.TransientObjects.CreateNameValueMap

' Create a DataMedium object
Dim oDataMedium As DataMedium = ThisApplication.TransientObjects.CreateDataMedium

' Check whether the translator has 'SaveCopyAs' options
If DXFAddIn.HasSaveCopyAsOptions(oDocument, oContext, oOptions) Then

Dim strIniFile As String
strIniFile = "C:\dxf_export.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 = oFolder & "\" & oFileName &".dxf"

'Publish document.
DXFAddIn.SaveCopyAs(oDocument, oContext, oOptions, oDataMedium)
0 Likes