Howto python fillet a track

Ah right sorry now I understand. I must say I’m not sure what the rules are but I wrote the fillet tracks tool (and corresponding constructor inSHAPE_ARC) so I’m happy if you’d like to use a derivative of that in your plugin.

To make sure you can “drag-resize” the arc tracks you create, you need to ensure thar start point of the arc track matches the end point of the previous track. Similarly, the end point of the arc track must match the start point of the next one.

Glad someone appreciates it :laughing: It took me a good while to make it look sensible in ascii art.

3 Likes

Is there a way to create an arc using python for a i.e. Mask layer (like a drawing on Mask Layer) to free the area over a track?

This is the way I use my Solder Mask Expander plugin.
In kv5 I use a discretization of the arc, but in 5.99 I would like to use a real arc.

It seems to me ATM there is no way to create an Arc in a different layer than Cu through python code.
(There is instead a way using the Gui)

1 Like

I havent tested it but I think you want PCB_SHAPE, and use the functions SetShape (to define the PCB shape as an arc with SHAPE_T::ARC) and SetArcGeometry to set the actual geometry.

I’m not sure if SHAPE_T is exposed in python but basically SHAPE_T::ARC is equal to 2 as defined in the C++ code

import pcbnew
from pcbnew import *
b=pcbnew.GetBoard()
new_arc=PCB_SHAPE()
new_arc.SetShape(SHAPE_T)
p1= wxPoint(203200000, 127000000)
md= wxPoint(221160512, 134439488)
p2= wxPoint(228600000, 152400000)
# new_arc.SetArcGeometry(aStart: 'wxPoint', aMid: 'wxPoint', aEnd: 'wxPoint')
new_arc.SetArcGeometry(p1,md,p2)
# new_arc.SetStart(p1)
# new_arc.SetMid(md)
# new_arc.SetEnd(p2)
new_arc.SetWidth(250000)
new_arc.SetLayer(pcbnew.F_SilkS)
b.Add(new_arc)
# pcbnew.SaveBoard("./test.kicad_pcb",b)

Here a sample code that should work…
But the result is a line instead of an arc.
The format inside the file is ‘gr_line’ instead of ‘gr_arc

Moreover, executing the Save code (last commented line), pcbnew just crashes.

I also found a nasty error… designing a simple 90 deg Arc with the Gui and pressing Edit and simply confirm the Arc will rotate… probably because Start point is mangled with Center point in the pcbnew code…

Application: KiCad PCB Editor (64-bit)

Version: (5.99.0-11630-gc5e195bdff), release build

Libraries:
wxWidgets 3.1.5
libcurl/7.74.0-DEV Schannel zlib/1.2.11

Platform: Windows 10 (build 18363), 64-bit edition, 64 bit, Little endian, wxMSW

Build Info:
Date: Aug 3 2021 21:00:05
wxWidgets: 3.1.5 (wchar_t,STL containers)
Boost: 1.75.0
OCC: 7.5.0
Curl: 7.74.0-DEV
ngspice: 34
Compiler: Visual C++ 1928 without C++ ABI

Build settings:
KICAD_USE_OCC=ON
KICAD_SPICE=ON

test.kicad_pcb (2.1 KB)
arc-dwg.kicad_pcb (2.1 KB)

Should be SHAPE_T_ARC

thanks, this solves the arc
… still I get a wrong Arc
test2.kicad_pcb (2.1 KB)
it seems that editing an arc with a negative angle can give a wrong design
arc1.kicad_pcb (2.5 KB) (both arcs have been placed by hand)

here the Arc Editing with wrong behavior…
simply clicking on ‘E’ and confirming the values the Arc gets flipped:


(note: this seems to be an issue in win only)

I cant reproduce on latest nightly. Might be some state leftover after your script. What did you do to generate?

Application: KiCad PCB Editor (64-bit)

Version: (5.99.0-11640-gb6664eecf2), release build

Libraries:
	wxWidgets 3.1.5
	libcurl/7.74.0-DEV Schannel zlib/1.2.11

Platform: Windows 10 (build 19041), 64-bit edition, 64 bit, Little endian, wxMSW

Build Info:
	Date: Aug  5 2021 20:59:33
	wxWidgets: 3.1.5 (wchar_t,STL containers)
	Boost: 1.75.0
	OCC: 7.5.0
	Curl: 7.74.0-DEV
	ngspice: 34
	Compiler: Visual C++ 1928 without C++ ABI

Build settings:
	KICAD_USE_OCC=ON
	KICAD_SPICE=ON

I simply draw the arc manually… have you tried with the attached above board? (arc1.kicad_pcb)

I confirm that with 5.99.0-11640-gb6664eecf2 this seems solved.
There is still some issue with building the Arc as drawing… I will post lately an issue example.

2 Likes

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.