WARNING! This code is not pretty! This is tourniquet code I wrote to solve a problem with a time budget of about zero seconds. The design pattern used was “fast as hell”. It’s not easy to maintain. Error checking is probably non-existent. This “prototype” has value, though, and there’s no reason it should die so I’m putting it here.
Github: https://github.com/brandondrury/RefDesGenerator
Some people who design circuit boards do not believe in reference designators. You know, the little text by the resistor that says “R1”, etc.
So I whipped this up to generate reference designators out of thin air for the sake of getting the customer a quote. The intention is to print the output in terminal, copy and paste it into a new, reference designator column in Excel. The assumption is we were provided the quantity of each component on the board. So if (22) 100nF capacitors are required, the customer would give us “22”. The script will turn that “22” into C1 – C22, although it won’t necessarily use reference designators that follow convention. In fact, in this case, it’s better if the reference designators are obviously weird/wrong so it will be clear that they should be fixed with a “real” BOM with “real” reference designators before production.
This is a basic utility that saved a lot of time in very specific situations.
Use
- Open RefDes_Gen.py in your Python editor.
- See “EDIT THIS” at the top. This is a Python list of all the component quantities in order. The recommended approach is to copy the QTY quantity from the original BOM, paste it in Notepad++ and replace the “\r\n” with a comma to generate this Python list.
- Run the script
- The resulting output can be copied and pasted into a new column in Excel.