📜 ⬆️ ⬇️

As I wrote the biggest script for Altium Designer

15680 lines, 800 053 characters - exactly this size today is my script created inside Altium Designer - a system for developing printed circuit boards.

image

Start


It was 2014, I worked as a design engineer, developed printed circuit boards. Military acceptance, design of the full design documentation (CD), normative control ESKD - all this makes Australian-Chinese-American software, which is the Altium system, tremble. Since they are alien to the Soviet guests, the old instructions and standards for the design of drawings. One employee of our department sometimes spent the whole work shift, so that the drawing of the board satisfies all the rules and regulations on the design of the design documentation.
Now it is done in 10 minutes.

I decided that it was possible to simplify life for myself and for another ten people at work. I started to understand, I found that there is an open API, I began to look at examples and voila, my first script for Altium already draws a line on the board - there is no limit to joy.
')
Little by little I was expanding my programming knowledge, because before that I hadn’t come across much of it, I remember a pendulum in the university I wrote for a semester and that's it.

First interface


It got to the point that the interface had to be done, at the very beginning it was:

image

This version already knew how to draw dimensions, callouts with arrows.

It should be understood that there was no specific explanation in the documentation, no one had any experience in using functions from the API either, only some githaba scripts and standard altiumovskie. Description on the wiki to this day from the category:

SetState_Enabled method (IPCB_Primitive interface) Syntax Procedure SetState_Enabled (Value : Boolean); Description Example See also IPCB_Primitive interface 

And the whole description, although by trial and error it was possible to determine how it works.

Every new time, the introduction of new functions was enjoyable, because when you see how people use your work and everything turns out - that’s not why programs are being created. At this stage, the time for drawing up drawings has already been reduced almost by half.

Development


The next version already looked like this:

image

She already knew how to insert sheets into the board, to stroke polygons for a drawing, to insert a grid and other elements for a drawing.

The main problem was that the Altium development environment is a system for developing printed circuit boards. It does not have enough tools to design a CD, and even more so according to Russian standards. Basically, scripting expanded the standard environment toolkit so that you could also develop a CD and print it out.

For example, I inserted the insertion of sheets of different formats directly into the code, did not begin to make separate files. I applied excel tables for this, inserted a format file with my hands into the pcb file, selected all the properties of all lines, their coordinates, widths, coordinates of texts, etc. and put it all in the usual array. Then, the script in turn created each of the formatting lines in the board file itself. And so for each sheet of all formats.

Our days


Now the program looks like this:

image

image

I have never been a designer, sometimes I had to sculpt buttons, I looked at the most famous CAD systems, how menus, settings, drop-down buttons and so on were made there.

Here is an example of the script itself.
image

image

Total on board:


and much more.

A lot of nerves, strength, patience, sleepless nights - spent. We make drawings at work - priceless.

The script is written by me alone for the fourth year, and without the use of the gita, dark themes and other things). Only pascal, only hardcore. Thank you for listening to the end, I will be glad to communicate!

An example of a decorated drawing inside the PCB

Version of the program to try

Source: https://habr.com/ru/post/431848/


All Articles