Custom scale for a true PCB view

Hello, I started learning and using KiCAD due to some it’s features not available in the ECAD which I’ve been using for years. But some features I got used to have are missing in KiCAD so I want to make a request if it makes sense to others.
I often use a feature in my ECAD to set a CUSTOM scale for viewing. This allows to do a magic : I get a precise true size of PCB to evaluate the placement of some components (usually large modules, Caps, power resistors, connectors, etc.)
Such true view allows quite intuitive placement which takes many specs into consideration without doing rational analysis and calculations (magic of a subconscious mind…) .
When this feature (CUSTOM SCALE) is available, then user plays with scale numbers only once, measuring the rendered PCB to find out which scale gives the true size. Then this number is saved and choosing it reveals the true size.
I use it practically with every PCB design for years so it would be a “long talk” trying to explain it’s usefulness .
As additional “bonus” would be nice to have a hot key which switching this scale ON , and next click would switch back to a “working” scale.
Of cause such CUSTOM scale would be also useful in PCB 3D viewer.

Since this is dependent on the display, perhaps all that’s needed is a calibration mode where you put a measuring tape over the screen and then tweak a “knob” until you get true size and then capture the magic factor for subsequent use.

Sorry, what is this “knob” you are talking about and what is a “magic factor” ? Do you mean the scale number?

The knob is whatever UI is developed to allow the user to change the scale until the screen scale matches real life. The magic factor is the scale number. This so that the user doesn’t have to type in a number but provide it interactively without being aware of it.

I do not see such UI in KiCAD so I don’t know which software do you mean here.
KiCAD has a “view->Zoom” option and a bottom status field reporting the Zoom/scale number. So I am suggesting a simple addition of the custom zoom/scale in this code. May be even clicking in the Zoom status field allowing to enter and save a custom number. Writing another graphic UI is not practical.

My suggestion was to develop one. Surely it’s more user friendly to adjust the scale using sliders, arrows, and other UI widgets than to type a number into a text box. That’s old school thinking. KiCad already uses a lot of UI widgets.

to find a perfect scale for a true view is done only once. Super-UI or a simple text field it does not matter. To make a special UI for such simple thing is overkill. Then simply a hot key can switch to that zoom.

I think you have not written GUI software. There are already many widgets available in GUI toolkits, as well as ways of composing widgets.

Here’s a gallery of wxwidgets, the toolkit used by KiCad: wxWidgets: Screenshots of Different Controls

@Kaunas : you can achieve and use your goal (custom scale with 1:1 display on screen) if you use the existing tools and combine them with some creativity:

  1. only useful with kicad v7 upwards (due to “viewport”-feature)
  2. disable properties-panel, enable appearance panel
  3. take a ruler and measure the real horicontal width (in mm, or inch if you prefer) of the black pcb-canvas
  4. draw a horicontal dimension-item on the board with the exact length of the measured value.
  5. zoom out so that the dimension-item will need approximately 50%…75% of the screen-width
  6. use the “zoom to selection”-tool (CTRL+F5 as standard hotkey) to zoom exactly from left start to right end of dimension-item
  7. the pcb-editor now should display the dimension-item exactly from left to right edge of black pcb-canvas. So the real length (measured in step 3) should be the same as the dimension-item displayed length (drawed in step 4).
  8. read out the zoom-value from the statusbar (for step 10)
  9. If needed pan the view around until the board is visible on screen. On the right appearance-panel: define a new viewport (name it zoom_1:1).

With the defined viewport you could now always switch to that 1:1 zoom factor. Be aware that the saved viewports are project-related. So if you create a new project from scratch you have to repeat the steps. If you create the new project from an older project (with project->SaveAs from the kicad manager) the viewport will be preserved. Also remind other users of that project that the viewport is monitor-dependent.

For experienced users: The zoom-factor settings for the context-menu (RMB-click–>context-menu–>zoom–>predefined zoom-factors) are set in a settings-file. The file “pcbnew.json” contains a “zoom-factors”-section, so if you write the value from step 8 into this file you get the 1:1 zoom-factor permanent into the context-menu. (this advice is not tested)

This didn’t work for me, i added 1.1111111223, to the zoom_factors-Array which already has a list of values (some of them are empty), i inserted them so that the list is still sorted. I added them to all files i was able to find (/home/jp/.config/kicad/5.99/pcbnew.json /home/jp/.config/kicad/6.0/pcbnew.json /home/jp/.config/kicad/7.0/pcbnew.json /home/jp/.config/kicad/7.99/pcbnew.json).

Tested it on 7.99 and 5.1.9.

This does also not work for me. [Ctrl + F5] does nothing, even though it should do as mf_ibfeew suggests according to PCB Editor / Preferences / Preferences / Common / Hotkeys

There is another hack that may work. In KiCad’s configuration directory, the zoom factors for the drop down boxes are listed as text (I think JSON) I once edited that to make that list a lot shorter. You can probably enter custom zoom factors too. But do be aware that each sub program in KiCad has it’s own table, so make sure you edit the right table.

I did a little grep in KiCad’s config directory:

paul@cezanne:~/.config/kicad/7.0$ grep -in zoom *.json
3d_viewer.json:18:    "zoom_to_fit": true
3d_viewer.json:188:    "zoom_factors": []
cvpcb.json:12:    "zoom_to_fit": true
cvpcb.json:26:    "autozoom": true,
cvpcb.json:80:    "zoom": 1.0,
cvpcb.json:81:    "zoom_factors": []
cvpcb.json:164:    "zoom_factors": []
eeschema.json:75:    "zoom_to_fit": true
eeschema.json:293:    "zoom_factors": [
fpedit.json:17:    "zoom_to_fit": true
fpedit.json:175:    "zoom_factors": [
gerbview.json:16:    "zoom_to_fit": true
gerbview.json:134:    "zoom_factors": [
kicad_common.json:7:    "text_editor_zoom": 0,
kicad_common.json:34:    "center_on_zoom": true,
kicad_common.json:43:    "scroll_modifier_zoom": 0,
kicad_common.json:45:    "zoom_acceleration": false,
kicad_common.json:46:    "zoom_speed": 1,
kicad_common.json:47:    "zoom_speed_auto": true
kicad.json:13:    "zoom_to_fit": true
kicad.json:130:    "zoom_factors": []
pcb_calculator.json:49:    "zoom_to_fit": true
pcb_calculator.json:463:    "zoom_factors": []
pcbnew.json:40:    "zoom_to_fit": false
pcbnew.json:114:    "autozoom": true,
pcbnew.json:166:    "zoom": 1.0,
pcbnew.json:167:    "zoom_factors": []
pcbnew.json:219:    "zoom_factors": []
pcbnew.json:438:    "zoom_factors": [
pl_editor.json:14:    "zoom_to_fit": true
pl_editor.json:109:    "zoom_factors": []
symbol_editor.json:12:    "zoom_to_fit": true
symbol_editor.json:94:    "zoom_factors": [

I’m not entirely sure, but it probably is the table starting at line 438 of pcbnew.json.

I do recommend to just copy the whole configuration directory to a backup. (I prefer to add date in ISO8603 format to the names of backups.) This makes it easy to find whatever you edited with a program like meldmerge

I am perplexed. How much time does it take to find the workaround vs to update the KiCAD code by using already available pieces of code (ex. the custom grid entered by user and saved into the configuration file) and repeat this code in the custom entered zooming/scaling factor ???
Unfortunately I am not capable today to spend time on learning the architecture of the KiCAD code and just jump in and change the code as I would do 20 years ago… I am older and my project is large and time consuming… I was simply encouraged recently by the news that KiCAD got boost from the companies and have a permanent development team… so I got impression that it is actively developed so decided to try…

How much time does it take to find the workaround

2 minutes. And 5 minutes to write my answer. It’s just that one needs to know the used tool. And the right approach for the own mind: it’s not necessary to have for every special task a special tool, it’s better to use the existing tools and combine them flexible.

versus time vs to update the KiCAD code by using already available pieces of code …

nearly infinite time - my pc-coding skills are very bad.

so I got impression that it is actively developed

That impression is correct.

It’s not a question of complexity, but of available time of people knowledgable with KiCad and willing to work on it. There are currently around 1500 open issues for KiCad listed on Gitlab.

If you are capable and willing to fix this, then start by opening an issue for it on gitlab first, before you go work on it.

I also noticed that zooming in the PCB editor, does change the listed zoom level, but it only shows one of the predefined zoom scales. That could also be improved. Being able to just type in a zoom scale would also be nice…

contradictory statements…
to re-use the already working code in KiCAD by a development team is in minutes not in hours and nobody else should look for a workaround.
To enter a custom zoom/scale number is no more “special” than entering a custom grid factor.
Typical task for every developer… and basic too that’s why it is already done for a grid.

You know that KiCad is open source?
You are welcome to create a patch and make a merge request.

Here is the official GitLab repository: KiCad / KiCad Source Code / kicad · GitLab
You can read about how to contribute to the KiCad source code here: Contribute | Developer Documentation | KiCad

You should write in your first post that nobody should look for a workaround for you. As you didn’t written it someone spend some time trying to help you and then he read that he should not did this.

Following your suggested steps shows the “real length” blown up to the whole window which is not a true visible size of PCB as per this topic. Status bar surely shows "real size’ but the shown size is not real. The intent of “zoom to selection” is just that : zoom out the selection of interest to fill the window (not to see it’s true size)

Piotr, you are right. I apologize.

Following your suggested steps shows the “real length” blown up to the whole window which is not a true visible size of PCB as per this topic

Than you didn’t followed my steps closely enough. (I have tested my steps prior to writing).
At the end of my descrition the screen is physically zoomed to 1:1 display. Every line on the screen equals the same length if you compare with a physical ruler hold onto the screen. (I understood that as your goal)