svg-pcb icon indicating copy to clipboard operation
svg-pcb copied to clipboard

KiCad export: component refdesing using label instead

Open ducky64 opened this issue 1 year ago • 1 comments

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?

ducky64 avatar May 19 '23 19:05 ducky64

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.

leomcelroy avatar May 30 '23 15:05 leomcelroy