13 Replies Latest reply on Jul 17, 2012 2:19 PM by Patrick.Cashman

    Grow/Shrink board outline or other polygon

    Patrick.Cashman

      Does anyone know of a way to grow/shrink a polygon shape programatically?

       

      I've explored all the functionality under document.BoardOutline, BoardOutline.Geometery, and the Keyin command tool.

       

      So far nothing.

       

      A comprehensive list of keyin commands would be very useful.  I cannot find it in the help.

       

      Also there is an undocumented feature under BoardOutline: CloneInternal.  Nothing in the help on that.  It also exists under UserLayerGfx and in a couple of other places.  Does anyone know what it does?  It sounds like it would make a copy of the board outline on some other layer, but who knows what layer that might be?

       

      Thanks in advance for any input,

       

      -Patrick

        • 1. Re: Grow/Shrink board outline or other polygon
          john_dube

          Hi Patrick,

           

          You can grow/shrink polygons using the Mask Engine.  Look at the Automation Pro Batch Engines documentation, specifically the Mask.Oversize method.

           

          I don't know about the BoardOutline.CloneInternal method, but if it's undocumented and even uses "Internal" in the method name, it's not a good idea to use that in your script.

           

          John

          • 2. Re: Grow/Shrink board outline or other polygon
            peter.kurlak

            Use the PutBoardOutline method.  Here's a Python example that sets the board outline to 26" x 26":

             

            # board outline points array

            maxBO = [[0, 26000, 26000, 0], [26000, 26000, 0, 0], [0, 0, 0, 0]]

             

            curBOWidth = self.pcbDoc.BoardOutline.Geometry.LineWidth


            logger.info("Expanding board outline")

            if self.pcbDoc.PutBoardOutline(4, maxBO, curBOWidth) is None:

                logger.fatal("Could not expand board outline to: %s" % maxBO)

                sys.exit(-1)

            • 3. Re: Grow/Shrink board outline or other polygon
              Patrick.Cashman

              John,

               

              I implemented the Mask functionality with the following code:

               

                      bo = pcbdoc.BoardOutline

                      geom = bo.Geometry

                      pts = geom.PointsArray

               

                      msk = CreateObject("MGCPCBEngines.MaskEngine")

                      mskbo = msk.Masks.Add()

                      mskbo.Shapes.AddByPointsArray(ubound(pts, 2) + 1, pts)

                      mskbo.Oversize(15.5, 1, 0)

                      shps = mskbo.Shapes

                      For Each shp In shps

                          pts = shp.PointsArray

                      Next

               

                      draw = pcbdoc.PutFabricationLayerGfx(64, 0, 31, ubound(pts, 2) + 1 , pts, false, nothing, 0)

               

              The results are not satisfactory.

               

              - The minimum resolution of the Oversize function appears to be 1 mil.  Location of the new object will be set on a 1 mil grid minimum.

              - Curves in the host object are not all interepreted correctly.

               

              Doing a side-by-side comparison with the output of a manual Grow/Shrink command on the same base object produces substantially different results. Here is a picture of the comparison:

               

              (red is board outline (source object), blue is created with Grow/Shrink (manually), brown is created with Oversize)

               

              oversize_vs_grow-shrink.jpg

               

              As you see, the CCW curve was not interpreted correctly. An adjacent CW curve was created properly.  Not so apparent in this image is that the Oversize ofjects are typically off a bit in any place where the source object is not on a 1mil or greater grid.

               

              Have I done something wrong here?  If not, is there any other way to do this that actually works?

               

              Thanks,

               

              Patrick

              • 4. Re: Grow/Shrink board outline or other polygon
                Patrick.Cashman

                Thank you Peter.

                 

                What I'm trying to do is replicate the existing board outline on another layer, offset to the outside of the current board outline, not create or modify the board outline.

                 

                The objective I have is to create contour shapes that exactly follow the board outline.  This is for the purpose of drawing cutouts that will be used for depanelization.

                 

                Any other ideas you have will be welcome.

                 

                -Patrick

                • 5. Re: Grow/Shrink board outline or other polygon
                  peter.kurlak

                  Have you tried using the PutContourEx method?  You could create a points array offset from the board outline's points array.

                  • 6. Re: Grow/Shrink board outline or other polygon
                    john_dube

                    Hi Patrick,

                     

                    The resolution is 1nm by default, it can be set on the MaskEngine.

                     

                    You should supply the units enumerator, and work with microns or database units if you need additional precision.

                     

                    Not sure what is wrong with the arcs, maybe that is due to the resolution.

                     

                    John

                    • 7. Re: Grow/Shrink board outline or other polygon
                      Patrick.Cashman

                      Peter, that is exactly what I'm looking for and it works very well.  Thank you for the tip.

                       

                      -Patrick

                      • 8. Re: Grow/Shrink board outline or other polygon
                        Patrick.Cashman

                        Or not.  There are flaws in the PutContourEx output as well.  Arcs are not interpreted correctly, resulting in an extra arc going the wrong way at the beginning and/or end points of the arcs that are supposed to be there.  Here's an example:

                         

                        PutContourEx_output.jpg

                         

                        I have verified that the pointsarray used as input to this does not have the extra, unwanted arcs present, and that the arc direction in the pointsarray is correct for each one.

                         

                        Back to the drawing board.

                         

                        What kills me about this is that the Grow/Shrink functionality is exactly what I want but it's not available to Automation.  I'm contemplating external abuse of the Properties window and its controls to manipulate that.  I'd rather not, but I also don't want to write all the code to do the math of recreating the offset polygon myself.

                         

                        I guess it's time to put in an SR for this.  Any chance the Mentor folks will either fix this or expose the Grow/Shrink?

                        • 9. Re: Grow/Shrink board outline or other polygon
                          Patrick.Cashman

                          Success.  I found the automation for the Grow/Shrink command.

                           

                          good_output.jpg

                          • 11. Re: Grow/Shrink board outline or other polygon
                            clive.robinson

                            Hi Pat,

                             

                            Can you please share the automation for the Grow/Shrink command.

                            • 12. Re: Grow/Shrink board outline or other polygon
                              bleslie

                              Hi Pat,

                               

                              Can you share how to access the grow/shrink command in automation?

                              • 13. Re: Grow/Shrink board outline or other polygon
                                Patrick.Cashman

                                OK, guys. Here it is.

                                 

                                Here is what happens:

                                 

                                1. Get a reference to the gui

                                2. Set draw mode.

                                3. Get a reference to the Expedition PCB window from Windows Automation

                                4. Try to find the Properties window that belongs to the Expedition PCB window

                                5. If the Properties window is not up, raise it.

                                6. Get a reference to the board outline.

                                7. Get the geometry of the board outline.

                                8. Get the points array from the geometry

                                9. Draw an object on a fabrication or user layer with this points array.

                                10. Select the object.

                                11. When the object is selected, the Properties box acquires information about it

                                12. Find the Grow/Shrink box in the Properties Window and set focus on it.

                                13. Use the SendKeys command to put a value in the box.

                                14. Use the SendKeys command to fire the Enter key.

                                 

                                I'll admit that this method is not very elegant.  It would be nice if there was an automation function to access the command.