3 Replies Latest reply on May 19, 2014 1:28 PM by andrew.french

    How to create a new user layer?

    andrew.french

      I'm writing a script that is going to walk the cells in a library and for any assembly text that is not a ref des or part number, I want to copy it and add it to a new user layer called "Cell Notes" and then delete the original assembly text.  I can do everything just fine except I'm having issues creating or even getting the new user layer.

       

      I've also tried just pre-defining the user layer manually in the library but even the line below returns null.  Not sure what I'm doing wrong here.

      MGCPCB.UserLayer CellNotes = ExpDoc.FindUserLayer("Cell Notes");

        • 1. Re: How to create a new user layer?
          andrew.french

          Okay, I was able to grab an existing user layer now.  Had my libraries mixed up where I had the layer created, so I was trying to grab it in a library that didn't exist.  dummy.

           

          Still would be nice to know how to programatically create a user layer though.

          • 2. Re: How to create a new user layer?
            Patrick.Cashman

            Give this a try:

             

            Sub create_clear_gerber_userlayers()

                    Dim lyrname As String

                    Dim ulr As MGCPCB.UserLayer

                    Dim ulgfxs as MGCPCB.UserLayerGfxs

             

                    lyrname = "Gerber_Top"

                    ulr = pcbdoc.SetupParameter.PutUserLayer(lyrname)

                    pcbdoc.activeView.DisplayControl.userLayer(lyrname) = True

                    ulgfxs = pcbdoc.UserLayerGfxs(, lyrname)

                    ulgfxs.Delete

             

                    lyrname = "Gerber_Bottom"

                    ulr = pcbdoc.SetupParameter.PutUserLayer(lyrname)

                    pcbdoc.activeView.DisplayControl.userLayer(lyrname) = True

                    ulgfxs = pcbdoc.UserLayerGfxs(, lyrname)

                    ulgfxs.Delete

             

            End Sub

             

            I'm not clear if you are trying to do this in the Cell Editor or in Expedition.  It works for Expedition.  I haven't looked into doing this in the Cell Editor.

            • 3. Re: How to create a new user layer?
              andrew.french

              ahh that makes sense that the call would be under the setup parameters since thats where you would do it in the GUI.  I haven't tested it but I don't see any reason why that wouldn't work.  Thanks Patrick!