swill / kad

Keyboard Automated Design (KAD) is a Golang library for designing mechanical keyboards
http://builder.swillkb.com
GNU Affero General Public License v3.0
232 stars 58 forks source link

Creating a custom switch geometry #5

Open RichardBronosky opened 6 years ago

RichardBronosky commented 6 years ago

I'd like to add a custom geometry to https://github.com/swill/kad/blob/master/key.go#L10-L20 that I'd assign const SWITCHSOCKET = 5 It would consist of the 5 holes for PCB mounting an MX switch, but the 2 for the contacts would be enlarged to fit Kailh sockets. It looks like a switch is just a Path which is just an array of Points which is just 2 float64s. And since CirclePolygon returns a Path, which can be appended easily... This should be "easy".

But, what I'm unsure about is:

Please advise.

RichardBronosky commented 6 years ago

Doh! I just realized that the Cherry Stabilizer that I was looking at is one piece! By looking at the Alps Stabilizer, I notice that multiple Paths are created and appended to the CutPoly for that layer, which is just an array of Paths.

I would have picked up on that if had finished reading the Draw function down to the part where it also appended to the CutPolys rather than stopping when I got to the case where the switch_path is defined.

I'd still appreciate any suggestions/hint you have. I'm quite new to golang. (I had to Google: Function declaration syntax: things in parenthesis before function name. 🤦 )

swill commented 5 years ago

Sorry for the delay getting back to you. I am having a bit of a hard time trying to follow what you are trying to do, so maybe we can review together what you are trying to do.

One thing to note is that you are able to create a cutout (or set of cutouts) and apply them at each switch location, so this should give you a way to adapt the switch cutout if you need to.

Check the following documentation if you haven't already:

Let me know if you need additional information or if you are still struggling with this.