How to add components using loop in Eagle PCB script

eagle

Eagle command language contains the ADD function but not loops. Eagle ULP contains loops but no function to add a component. Under these circumstances, how does one add components e.g a lot of LEDs into a schematic using a loop?

Best Answer

It is possible to use a ULP to execute editor commands, but only in a very non-obvious way: The built-in exit() function can be given a string that is executed immediately after the ULP has exited:

exit("ADD whatever...");

See the file cmd-draw.ulp for a complete example.