8 Replies Latest reply on May 20, 2016 2:49 AM by fuba

    Automated Screenshot of xPCB Layout Layers

    fuba

      Hello,

       

      I am looking for a way, to make automated screenshots of layout sections.

      Currently to do this, I am using the window handle of the xPCB Aplication.

       

      • pcbApp.Gui.HWND

       

      when I do a shot then I get the complete window, but no artwork, just the black window.

      shot-nok.jpeg

      This shot here is ok, but made with a screenshot tool like (Win7 Snipping Tool)

      shot-ok.png

      The Screenshot .Net class I have is working, I am using it also for other projects.

       

      Another Idea was now, to search the xPCB window for subwindows. I did that, and found around 100 Handles.

      I shooted them all, but none of them included my PCB/artwork.

       

      Has someone an Idea, how to get fractions / sections / excerpts  of a whole PCB / View to a bitmap, or PDF or ...

      Or how to get the right handle (HWND) of the PCB window ?

       

      Thanks in advance

       

      Stefan

        • 1. Re: Automated Screenshot of xPCB Layout Layers
          kendall_hiles

          Fuba;

           

          You can use Automation PRO to automatically generate PDF's of anything you want in the PCB.  There is an example in AATK.

           

          -kendall

          • 2. Re: Automated Screenshot of xPCB Layout Layers
            fuba

            Dear Kendall,

            thanks for the answer. I am aware of that feature in 'Automation PRO',

            but is it possible with the automation Pro Engine, to shoot/print only

            sections and not the whole design ?

             

            My target is, to have screenshots of a section showing each layer,

            for supplier reviews, in regards to the PCB artwork.

             

            Anyway, I will check AATK and see what I can find.

             

            Thanks

             

            Stefan

            • 3. Re: Automated Screenshot of xPCB Layout Layers
              fuba

              Hi all,

               

              I tried in xPCB via the Menu: Edit->Copy Bitmap To Clipboard

              but it is also not satisfying, because it only copies only the selected graphics and text to the clipboard.

              And then, when pasting, it, the graphic is worse, because it still has the highlighting of the selction,

              what is really poor.

               

              Thanks

              • 4. Re: Automated Screenshot of xPCB Layout Layers
                Patrick.Cashman
                1 of 1 people found this helpful
                • 5. Re: Automated Screenshot of xPCB Layout Layers
                  fuba

                  Patrick,

                  thanks. The link you provided was good input. They did it a little bit different that the way I dit it.

                  Now I have my Image. I am also not working with the HWND of the Application, because it gives

                  me the frame/GUI around. I have now a process of defining an own "RECT" Window, and shoot this one.

                   

                  But all this leads me to a next issue.

                   

                  How can I enable a Layer (by Code / .Net / VB) , like when clicking on it in the Display Control ?

                   

                  layerControl.png

                  • 6. Re: Automated Screenshot of xPCB Layout Layers
                    Patrick.Cashman

                    With the current release, the Automation of Display Control is quite functional, and very different than it was in 7.9.x and before.  You can do anything you want to with it, as before, it's just different.  Problem is that the help files are both incorrect and inadequate, so there's a bit of wandering in the dark. 

                     

                    Good news is that someone at Mentor made an Excel spreadsheet with VBA code in it that demonstrates how to do it. It's in the Mentor install tree at:

                     

                    C:\MentorGraphics\EEVX.1.2\SDD_HOME\standard\examples\pcb\Automation\Excel\DisplayControl.xls

                     

                    There are examples in there, in the VBA code, of how to interact with the Display Control.  Even with this, it's still kind of confusing, until you figure out which group a particular layer or items belongs to. Here is some code that shows a number of commands used to turn on and off different layers:

                     

                         Public dsp As MGCPCB.DisplayControl

                         Public view As MGCPCB.View

                         Public gui As MGCPCB.Gui

                         Public globl As MGCPCB.GlobalDisplayControl

                     

                    Public Sub setup_layers()

                        

                             'Do all the common items

                    '-----------------------------------------------------------------------------------------------------

                             'Turn off Route Objects

                             dsp.Option("Option.RouteObjects.Enable") = 0

                            

                             'Turn off Place Objects

                             dsp.Option("Option.PlaceObjects") = 0

                            

                             'Turn Board Items

                             dsp.Option("Option.Fiducials.Enabled") = 0

                             dsp.Option("Option.MountingHolePads.Enabled") = 0

                             dsp.Visible("Fabrication.Hole.Mounting") = 0

                             dsp.Visible("Fabrication.Hole.Contour") = 0

                             dsp.Visible("Board.ManufacturingOutline") = 0

                            

                            

                             'Turn off Drill Drawing

                             dsp.Option("Option.Fabrication.DrillDrawing") = 0

                            

                             'Turn off Fabrication Objects

                             dsp.Option("Option.Fabrication.CellItems.Bottom") = 0

                             dsp.Option("Option.Fabrication.CellItems.Top") = 0

                             dsp.Option("Option.Fabrication.TestPointItems.Bottom") = 0

                             dsp.Option("Option.Fabrication.TestPointItems.Top") = 0

                             dsp.Visible("Fabrication.Assembly.TestPoint.Text.RefDes.Bottom") = 0

                             dsp.Visible("Fabrication.Assembly.TestPoint.Text.RefDes.Top") = 0

                             dsp.Option("Option.Fabrication.AssemblyItems.Bottom") = 0

                             dsp.Option("Option.Fabrication.AssemblyItems.Top") = 0

                             dsp.Visible("Fabrication.SolderPaste.Bottom") = 0

                             dsp.Visible("Fabrication.SolderPaste.Top") = 0

                             dsp.Visible("Fabrication.Assembly.Part.Text.PartNumber.Bottom") = 0

                             dsp.Visible("Fabrication.Assembly.Part.Text.PartNumber.Top") = 0

                            

                            

                             'Turn off some of the Top Silkscreen items

                             dsp.Visible("Fabrication.Silkscreen.Part.Text.PartNumber.Top") = 0

                             dsp.Visible("Fabrication.Silkscreen.Generated.Top") = 0

                             dsp.Visible("Fabrication.Silkscreen.TestPoint.Probe.Top") = 0

                             dsp.Visible("Fabrication.Silkscreen.TestPoint.Text.RefDes.Top") = 0

                            

                            

                             'Turn off user layers

                             'dsp.Option("Option.UserDraftLayers.Enable") = 0

                            

                             'Turn off coloring nets and net classes

                             dsp.Option("Global.Option.ColorByNetClass.NetClasses.Enable") = 0

                             dsp.Option("Global.Option.ColorByNetClass.Nets.Enable") = 0

                            

                            

                             'Now do the specific items based on paramaters

                    '-----------------------------------------------------------------------------------------------------

                             Debug.Print("txt_type is " & txt_type)

                             Debug.Print("side is " & side)

                             Select Case txt_type

                                 Case 1    'assy

                                     'Turn off Soldermask Objects

                                     dsp.Visible("Fabrication.SolderMask.Bottom") = 0

                                     dsp.Visible("Fabrication.SolderMask.Top") = 0

                                    

                                     'Turn off Bottom Silkscreen

                                     dsp.Option("Option.Fabrication.SilkscreenItems.Bottom") = 0

                                    

                                     'Turn off Top Silkscreen

                                     dsp.Option("Option.Fabrication.SilkscreenItems.Top") = 0

                                    

                                     Select Case side

                                         Case 1    'top

                                             gui.ActiveRouteLayer = 1

                                            

                                             dsp.Option("Option.Fabrication.AssemblyItems.Top") = 1

                                             dsp.Visible("Fabrication.Assembly.Part.Text.RefDes.Top") = 1

                                             dsp.Visible("Fabrication.Assembly.Part.Outline.Top") = 1

                                             dsp.Option("Option.Fabrication.AssemblyItems.Bottom") = 0

                                            

                                         Case 2    'bottom

                                             gui.ActiveRouteLayer = doc.LayerCount

                                            

                                             dsp.Option("Option.Fabrication.AssemblyItems.Bottom") = 1

                                             dsp.Visible("Fabrication.Assembly.Part.Text.RefDes.Bottom") = 1

                                             dsp.Visible("Fabrication.Assembly.Part.Outline.Bottom") = 1

                                            

                                             dsp.Option("Option.Fabrication.AssemblyItems.Top") = 0

                                            

                                     End Select

                                    

                                 Case 2    'silk

                                    

                                     dsp.Option("Option.Fabrication.AssemblyItems.Top") = 0

                                     dsp.Option("Option.Fabrication.AssemblyItems.Bottom") = 0

                                    

                                     Select Case side

                                         Case 1    'top

                                             gui.ActiveRouteLayer = 1

                                            

                                             dsp.Visible("Fabrication.SolderMask.Top") = 1

                                             dsp.Visible("Fabrication.SolderMask.Bottom") = 0

                                            

                                             dsp.Option("Option.Fabrication.SilkscreenItems.Top") = 1

                                             dsp.Option("Option.Fabrication.SilkscreenItems.Bottom") = 0

                                            

                                             dsp.Visible("Fabrication.Silkscreen.Generated.Top") = 0

                                             dsp.Visible("Fabrication.Silkscreen.Part.Text.PartNumber.Top") = 0

                                             dsp.Visible("Fabrication.Silkscreen.TestPoint.Probe.Top") = 0

                                             dsp.Visible("Fabrication.Silkscreen.TestPoint.Text.RefDes.Top") = 0

                                            

                                             dsp.Visible("Fabrication.Silkscreen.Part.Outline.Top") = 1

                                             dsp.Visible("Fabrication.Silkscreen.Part.Text.RefDes.Top") = 1

                                            

                                         Case 2    'bottom

                                             gui.ActiveRouteLayer = doc.LayerCount

                                            

                                             dsp.Visible("Fabrication.SolderMask.Bottom") = 1

                                             dsp.Visible("Fabrication.SolderMask.Top") = 0

                                            

                                             dsp.Option("Option.Fabrication.SilkscreenItems.Bottom") = 1

                                             dsp.Option("Option.Fabrication.SilkscreenItems.Top") = 0

                                            

                                             dsp.Visible("Fabrication.Silkscreen.Generated.Bottom") = 0

                                             dsp.Visible("Fabrication.Silkscreen.Part.Text.PartNumber.Bottom") = 0

                                             dsp.Visible("Fabrication.Silkscreen.TestPoint.Probe.Bottom") = 0

                                             dsp.Visible("Fabrication.Silkscreen.TestPoint.Text.RefDes.Bottom") = 0

                                            

                                             dsp.Visible("Fabrication.Silkscreen.Part.Outline.Bottom") = 1

                                             dsp.Visible("Fabrication.Silkscreen.Part.Text.RefDes.Bottom") = 1

                                            

                                     End Select

                             End Select

                     

                             gui.ActiveMode = 0

                        

                    End Sub

                     

                    This is not a direct answer to your question, and you have some head scratching ahead to figure out how to do what you want, but it will get you there eventually.

                    2 of 2 people found this helpful
                    • 7. Re: Automated Screenshot of xPCB Layout Layers
                      fuba

                      Ciao Patrick,

                      found also yesterday evening the xls-Worksheet you mentioned, but thanks again for the good support.

                      I modified the code in there to my needs. But still, quite tricky.

                       

                      In the VBA-Excel Macro, Mentor uses an enumeration for setting the states, which I couldn find in the DOC's,

                      so I set it up on my own. Maybe it is a question which *.tlb I am referencing in my Project,

                      but is their some documentation on the values ?

                       

                       Public Enum ePCBGraphicsItemState
                      
                              '# Copied from Excel Object Catalog
                              '# Could not be found in the Documentation
                              '# or in the Intelli Sense here
                              epcbGraphicsItemStateModifierIgnoreEnabled = &H8000000
                              epcbGraphicsItemStateModifierIgnoreOnOff = &H4000000
                              epcbGraphicsItemStateOffEnabled = &H0
                              epcbGraphicsItemStateOffNotEnabled = &H2
                              epcbGraphicsItemStateOnEnabled = &H1
                              epcbGraphicsItemStateOnNotEnabled = &H3
                      
                          End Enum
                      
                      

                       

                      Where is the difference between '...OnEnabled' and '...OnNotEnabled'

                      or '...OffEnabled' and '...OffNotEnabled' ?

                       

                      I am still confused, I have my Views now, save them via

                      ... .DisplayControl.SaveScheme(...
                      

                      that I can recall them later, but I still fight with the layers.

                       

                      I will go on investigating. So stay tuned.

                       

                      Thanks

                      • 8. Re: Automated Screenshot of xPCB Layout Layers
                        fuba

                        Ok, I found out that I was using the wrong *.dll or *.tlb

                        when I am using the *.tlb from here:

                         

                        C:\ProgramData\mgcSDD\win64\TLB\MGCPCB.tlb

                         

                        then I have the Enumeration mentioned above, and a few more functionalities,

                        like Setting the Colors/Pattern on the Layers, and creating color objects via

                         

                        Dim colO As MGCPCB.ColorPattern
                            colO = pcbApp.Utility.NewColorPattern(0, 255, 255, 0, False, False)
                        

                         

                        Bye