Quantcast
Channel: Mentor Graphics Communities: Message List
Viewing all articles
Browse latest Browse all 4541

Re: Using VB script to export IDF and DXF formats from Expedition PCB

$
0
0

Hi, its me again.

 

Thanks for all the support so far, now I have my Tool up and running, doing various exports for me.

My problem is now the DXF-Engine / Exporter.

 

I want to export all the Traces from the PCB Layers.

 

Below a cutout of my Macro, which gives me not the results I am expecting. It only exports me the last Layer.

I tried playing around with the layer names

  • passing only a number
  • passing "Traces Layer 1", "Traces Layer 2", ... (like mentioned in the DXF-Export Window)
  • passing "SIGNAL_1", "SIGNAL_2", ...(like mentioned in the xPCB Layout GUI)

But this all does not work well.

 

The best is, when I load the Scheme File, but this is something, I dont want for a few other reasons

(because it is static, does not include a solution for various PCB's with different amount of layers, ...)

 

Has anyone an idea here, what I am doing wrong ?

Why do I have different Layer Names (see image below), between the Display and the DXF Exporter ?

 

dxfExp-Layers.png

 

Now the Macro I am using.

 

  Public Shared Sub export_dxf()        '#        '# The usage of these engines through Automation        '# requires an Automation Pro license with the        '# exception of Drawing File Wizard.        '# Make a Reference to:        '# C:\MentorGraphics\EEVX.1\SDD_HOME\common\win64\lib\MgcPcbEngines.tlb or .dll        '# Connect via mgLaunch.exe               Dim sb As StringBuilder        sb = New StringBuilder        With sb            .AppendLine()            .AppendLine("Start: " & Now.ToString)            .AppendLine("dxf File creation")        End With        frmMain.UpdateRtb(sb.ToString, Color.BlueViolet)        Dim dxfEngine As MGCPCBEngines.DXFExport        dxfEngine = New MGCPCBEngines.DXFExport               If dxfEngine Is Nothing Then            MsgBox("Cannot obtain an Automation Object")            Exit Sub        End If        Dim outPath As String        outPath = IO.Path.Combine(pcbDoc.Path, "output", "DXF")        If not IO.Directory.Exists(outPath) Then            '# Create The Folder(s)            IO.Directory.CreateDirectory(outPath)        End If        Dim fn As String 'FileNAme        fn = IO.Path.GetFileNameWithoutExtension(pcbDoc.Name) & ".dxf"        Dim ffn As String 'FullFileName        ffn = IO.Path.Combine(outPath, fn)        With dxfEngine                       .DesignFileName = pcbDoc.FullName            '# This works best, having a Scheme File, and export it            '.Scheme(MGCPCBEngines.EEnginesSchemeType.eengSchemeTypeUser) = IO.Path.Combine(Application.StartupPath, "myDxf.edxf")            Call exportLayers(dxfEngine)            If 0 Then                '# section switched off for test of "exportLayers" Function                .FillPads = True                .MirrorOutput = False                .BoardContents = True                .DXFUnits = MGCPCBEngines.EEnginesUnit.eengUnitMM                Dim layerName As String                layerName = "SIGNAL_1"                Dim dxfLayerName As String                dxfLayerName = "Lay-0"                .PutElementExport(MGCPCBEngines.EEnginesElementType.eengElementTypeAssemblyRefDesTop, dxfLayerName, layerName, True)                .PutElementExport(MGCPCBEngines.EEnginesElementType.eengElementTypeTraces, dxfLayerName, layerName, True)            End If            .OutputFileName = ffn        End With        Try            dxfEngine.Go()        Catch ex As Exception            MsgBox(ex.ToString)        End Try        Call clsExport_utils.ListErrors(dxfEngine.Errors)        dxfEngine = Nothing        sb = New StringBuilder        With sb            .AppendLine()            .AppendLine("dxf - 'Drawing Interchange File Format' File")            .AppendLine("Created here:")            .AppendLine(clsUtils.createLink(outPath))        End With        frmMain.UpdateRtb(sb.ToString, Color.BlueViolet)    End Sub         Private Shared Sub exportLayers(dxfEngine As MGCPCBEngines.DXFExport)        Dim layerName As String        layerName = "dummy"        Dim dxfLayerName As String        dxfLayerName = "dummy"        Dim layIdx As Integer        layIdx = 0        For i = 1 To dxfEngine.LayerCount            layerName = "Traces Layer " & i            dxfLayerName = "L_" & i.ToString("00")            Try                dxfEngine.PutElementExport(MGCPCBEngines.EEnginesElementType.eengElementTypeTraces, dxfLayerName, layerName, True)            Catch ex As Exception                Console.WriteLine("cannot export: " & layerName & " -- " & dxfLayerName & " ---> " & ex.Message.ToString)            End Try        Next    End Sub         Public Shared Sub ListErrors(Errors As MGCPCBEngines.Errors)        Dim sbErr As StringBuilder        sbErr = New StringBuilder        Dim oError As MGCPCBEngines.Error        For Each oError In Errors            Select Case oError.Severity                Case MGCPCBEngines.EEnginesErrorSeverity.eengError                Case MGCPCBEngines.EEnginesErrorSeverity.eengFatalError                Case MGCPCBEngines.EEnginesErrorSeverity.eengWarning                Case Else            End Select            sbErr.AppendLine(oError.Severity.ToString & " - " & oError.ErrorString)        Next        frmMain.UpdateRtb(sbErr.ToString, Color.Red)    End Sub

 

 

Thanks Stefan


Viewing all articles
Browse latest Browse all 4541

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>