Announcements
Attention for Customers without Multi-Factor Authentication or Single Sign-On - OTP Verification rolls out April 2025. Read all about it here.
josiah_pekary
1029 Views, 3 Replies

iLogic SaveAs Autocad DWG only one sheet

I would like to know what the illogic code is to save an inventor drawing as an AutoCAD .dwg. However I only want to save the one sheet I specify. The current code I have below will save all the sheets, I want to specify which sheet it saves.

 

Version:1.0 StartHTML:00000145 EndHTML:00002174 StartFragment:00000294 EndFragment:00002142 StartSelection:00000294 EndSelection:00000294SyntaxEditor Code Snippet

Dim doc As DrawingDocument
doc = ThisApplication.ActiveDocument
doc.Sheets.Item("1202_GLASS PRINT:30").Activate

ThisDoc.Document.SaveAs("H:\EngCustomProducts\CustomGlass\" & Parameter("1202-GateASM.iam.JobNo") & "-MG12CF.dwg" , True)

 

Tags (1)

When working this problem by hand, there is a checkbox in the options wizard, that allows you to select a specific sheet or sheets.  When I saved that configuration into a *.ini file, I noticed an option that says "ALL SHEETS=No" under [EXPORT DESTINATION], however that file did not mention the sheet I selected.  So at least I know there is access to this option.

In this code, I export with a bit more direct control over the actual translator.  I suspect your answer lies in the oNameValueMap including something for the sheets to be printed.

    Public Sub ExportACAD(settingsFile As String, isDWG As Boolean)
        Dim invApp As Inventor.Application = TTSInventorTools.GetInventorApplication
        ' 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 informationto the translator.
        Dim oNameValueMap As NameValueMap
        oNameValueMap = invApp.TransientObjects.CreateNameValueMap()
        ' Create the name-value that specifiesthe 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

Not a complete answer but likely a point into the correct direction.

 

jvj

Searching the Programmers API, for these options to be spelled out, use the Index and search for Translator Options page (or ShowSaveCopyAsOptions Method\TranslatorAddIn Object\Translator Options in Remarks - how I found it).

Scroll down to the Export options for DWG and Definition of Export Values, and Sheets is listed as an option to manipulate.

jvj

Thank you this works.