Hi,
I’m looking for documentation on how to create copper zones programmatically. I typically refer to the API docs , is that the latest and greatest?
Searching the forum I get results from back in 2015 pointing to (at the time) hacky solutions and I was hoping for something more actual.
I tried some variations of the following with no success, can you guys point me in the right direction?
fs = 10e6
sps = pcbnew.SHAPE_POLY_SET(self.board)
sps.SetVertex(fs,fs)
sps.SetVertex(-fs,fs)
sps.SetVertex(-fs,-fs)
sps.SetVertex(fs,-fs)
sps.SetVertex(fs,fs)
z = pcbnew.PCB_ZONE(self.board)
z.SetLayer(pcbnew.F_Cu)
z.SetFilledPolyList( pcbnew.F_Cu, sps)
self.board.Add(z)
cheers,
stef
I think you need to use AddPolygon() (or possibly SetOutline() ) instead of SetFilledPolyList() for defining the zone outline.
Hi @Jonathan_Haas ,
thanks for the quick reply. I’ve tried what you suggested, both methods alone and also together, passing the same SHAPE_POLY_SET as before.
Same result, nothing shows up in the layout unfortunately
I’m not sure you’re creating the SHAPE_POLY_SET correctly. I believe you have to call Append(…) to add points.
But at the moment I don’t have time to mess around with this. I can create an example this weekend maybe.
mgyger
November 10, 2022, 2:17pm
5
There are many different ways but I’m using AddPolygon()
. To deal with differences of 5.1 and 6.0, I once create an unconnected kind of prototype zonedefaults
object and use that with a copy constructor. It might have changed in 6.99 again, though…
Continuing the discussion from Elektuur Style Symbol Library .
Oktizer
Oktizer is an Action Plugin to create octagonal looking pads and vias in the PCB Editor. It works somewhat similar to how KiCad 6.99 is currently doing teardrops but it also modifies pads.
Currently, there is no GUI (edit the python file to change corner rounding [radius 0.05 mm ≈ 2 mil] or chamfer ratios [29.29% and 20.71%]) and it needs to be copied to the plugins folder of KiCad 5.1 or KiCad 6.0 (it doesn’t need its own …
2 Likes
Thank you guys,
with the input from @mgyger (awesome code snippets man!), and fixing a bug of mine, I got it to work (see below). Other approaches might work as well but I didn’t test them.
fs = 10e6
points = (
pcbnew.wxPoint(fs,fs),
pcbnew.wxPoint(-fs,fs),
pcbnew.wxPoint(-fs,-fs),
pcbnew.wxPoint(fs,-fs)
)
z = pcbnew.ZONE(self.board)
z.SetLayer(pcbnew.F_Cu)
z.AddPolygon( pcbnew.wxPoint_Vector(points) )
z.SetIsFilled(True)
self.board.Add(z)
# fill board
filler = pcbnew.ZONE_FILLER(self.board)
filler.Fill(self.board.Zones())
pcbnew.Refresh()
cheers
stef
2 Likes
system
Closed
February 8, 2023, 4:16pm
7
This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.