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.
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)
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
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)
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?
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.
Have you tried using the PutContourEx method? You could create a points array offset from the board outline's points array.
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.
Peter, that is exactly what I'm looking for and it works very well. Thank you for the tip.
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:
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?
So...what is it?
Can you please share the automation for the Grow/Shrink command.
Can you share how to access the grow/shrink command in automation?
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.
grow_shrink.vb.zip 1.0 KB