leomcelroy / svg-pcb

Design PCBs in the Browser
https://www.leomcelroy.com/svg-pcb-website
GNU General Public License v3.0
64 stars 9 forks source link

KiCad export: component refdesing using label instead #57

Open ducky64 opened 1 year ago

ducky64 commented 1 year ago

Currently, KiCad export seems to generate refdes based on the Javascript variable name (and falling back to undefined if it is not assigned to a variable). However, this is inconsistent with the labels shown in SVG-PCB, which uses the label property of the object passed to board.add. Using the variable name also makes programmatic generation (e.g., array of LEDs in a for loop) difficult, since they all need to be given unique names (unless there's some container construct?).

Would it be possible to change the refdes generation to use the label property - both for consistency and to better support programmatic generation?

leomcelroy commented 1 year ago

I made the refDes the id of the component. It can be passed explicitly: const ic = board.add(thing, { id: "myRefDes" }). It defaults to a random alphanumeric string. This can be retrieved by ic.id.