9 Replies Latest reply on Aug 30, 2017 6:44 AM by .-.--.--

    toggle items in display control

    andrew_french

      One of my layout designers asked for a script where he could toggle certain things in the display control on and off like "Display Active Layer Only" using hot keys.  I know how to setup hot keys but I'm struggling to figure out how to toggle items on and off that live in the display control.  Anyone have any experience doing this that could help me out?  I see several items in "ActiveViewEX.DisplayControl" like "set_Option" but it crashes on me when I run it.

       

      Something like

      ExpDoc.ActiveViewEx.DisplayControl.set_Option("Display Active Layer Only", MGCPCB.EPcbGraphicsItemState.epcbGraphicsItemStateOnEnabled);

      seems like it should enable the "Display Active Layer Only".

        • 1. Re: toggle items in display control
          Patrick.Cashman

          I run the following script for that particular function.  It's in a .vbs file I call from my keybindings file. It's the old way, but still works with VX. 

           

          Option explicit

           

          dim app

          dim doc

           

          Set app = GetObject(, "MGCPCB.Application")

          Call Scripting.AddTypeLibrary("MGCPCB.Application")

           

          ' get the (licenced) active document

          Set doc = GetLicensedDoc(app)

           

          If not doc is nothing then

              

               if doc.activeview.DisplayControl.MiscItems(0) = True then

                   doc.activeview.DisplayControl.MiscItems(0) = False

               else

                   doc.activeview.DisplayControl.MiscItems(0) = True

               End if

              

              

           

          End if

           

          Set app = Nothing

          Set doc = Nothing

           

           

           

          Public Function GetLicensedDoc(appObj)

            . . .

          End Function

           

           

          If you want the new way, for VX releases, you'll have to search through the DisplayControl.xls file's vba code to find the right way to identify every object's setting.  In this case it would be something like:

           

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

           

          where dsp is the display control object. 

           

          The DisplayControl.xls file can be found in

           

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

           

          Last time I looked (several months ago) the help files on SupportNet for the display control were severely lacking, and in some parts completely wrong.  I'm not sure if they've updated it since then. It will take you a lot of searching and scratching your head with that vba code to figure out how to use automation with the new display control.  It's not particularly intuitive. 

          1 of 1 people found this helpful
          • 2. Re: toggle items in display control
            jeff@viavi

            Since Patrick already answered your question, I thought I let you know that there is a mouse stroke already defined to toggle the active layer display.  I have been using this method so long that it just seems like second nature to me

             

            • 3. Re: toggle items in display control
              andrew_french

              hmm, guess I need to take a look at those strokes again!  Thanks!

              • 4. Re: toggle items in display control
                andrew_french

                As always, pointing me in the right direction.  Thanks Patrick.

                 

                The documentation is downright atrocious and severely lacking syntax guidance in a lot of places. Glad someone else agrees.

                • 5. Re: toggle items in display control
                  jeff@viavi

                  I feel pretty darn lucky that I have Patrick.Cashman sitting right next to me.  He spoils us with all of the awesome automation that he writes!

                  • 6. Re: toggle items in display control
                    andrew_french

                    I was very close yesterday, just a matter of deciphering the proper syntax for specific items in the display control which are frustratingly not documented except in code in a buried example in the install tree. Display Active layer only would be "Option.AcitveLayerOnly"

                     

                    MGCPCB.View pcbView = ExpDoc.ActiveViewEx;
                                MGCPCB.DisplayControl dsc = pcbView.DisplayControl;
                                
                                if (dsc.get_Option("Option.Netlines.Enable") == MGCPCB.EPcbGraphicsItemState.epcbGraphicsItemStateOffEnabled)
                                {
                                    dsc.set_Option("Option.Netlines.Enable", MGCPCB.EPcbGraphicsItemState.epcbGraphicsItemStateOnEnabled);
                                }
                                else
                                {
                                    dsc.set_Option("Option.Netlines.Enable", MGCPCB.EPcbGraphicsItemState.epcbGraphicsItemStateOffEnabled);
                                }
                    
                    • 7. Re: toggle items in display control
                      thomasson

                      If you just want to toggle between active layers with the numeric keys there is already a button to activate this in the Smart Utilities toolbar.

                      SmartUtilities.jpg

                      Hint: Search for Smart Utilities User Guide on SupportNet

                      • 8. Re: toggle items in display control
                        juergen.hinterleitner

                        Thank you for that Diskussion.
                        I have realized now my wish as follows... (in KeyBindings)

                         

                        Sub PlaneOnOff()
                            If (Doc.ActiveViewEx.DisplayControl.Option("Option.Planes.Data.Enable") = epcbGraphicsItemStateOffEnabled) Then
                                Doc.ActiveViewEx.DisplayControl.Option("Option.Planes.Data.Enable") = epcbGraphicsItemStateOnEnabled
                            Else
                                Doc.ActiveViewEx.DisplayControl.Option("Option.Planes.Data.Enable") = epcbGraphicsItemStateOffEnabled
                            EndIf
                        EndSub

                        • 9. Re: toggle items in display control
                          .-.--.--

                          If you are having difficulty writing code to drive the VX Display Control, for which the option items are poorly documented (seeProvide Complete Documentation for Display Control ItemNames), try setting the environment variable MGC_ENABLE_DC_AUTOMATION_LOG to a value of 1, then launch the application, and display the Output tab from the View > Message Window menu entry.  Now, whenever you change a Display Control setting, the appropriate VB Script code is reported in the Output tab.  (If you don't have the Message Window visible, each DC change will result in the code displaying by MsgBox, but you won't want to operate in that mode for long.)