Fixing or Having a Desire to Edit Model Type, File-Paths, Footprints, Symbols... Etc

Occasionally the links to 3D-Models get broken yet, the Paths and, indeed files may appear good.
Some of Kicad’s footprints are linked to .wrl files while some to .step. Sometimes, perhaps .stp.
Some components have both .wrl and .step files in Kicad and which one to use is a User’s choice.

Only the .STEP files are usable for Exporting complete .STEP of the PCB. Thus, reducing the need for .wrl. There are approx 1.4 Gigs of .wrl so, system gets bloated (some Users, including me, delete them).

First: Know that, although User’s can create custom locations for the 3D-models, symbols and footprints, Links to them may get broken upon updating Kicad.
Thus, it’s best to use the Folder/locations that Kicad creates.

Second: When the links get broken, you can reset them individually. At most, Users probably won’t use more than 5% of Kicad’s symbols/Footprints/Models but, even if using only 20 of them, resetting the links individually is a bother.

You can Bulk Change links to the Model type (.step, .stp, .wrl) using various Text-Editors and/or Codes

You can also do it with the Code below after watching this video.
There are Two ways to do it with Code: 1) In a Python IDE or, 2) Using Kicad’s Python Console (either from the PCB-Editor or from the Schematic-Editor).

I duplicated Three Stock Footprint files ( .kicad_mod ) and set thier embedded link from .wrl to .tofu. Then, used the code to Bulk change ALL footprints (having links to .tofu) to .COFFEE

First Video shows using system Python IDE.
Second Video shows using Kicad’s Python Console (from PCB-Editor)

The Code walked through the Full ‘footprints’ folder and changed ALL the files with .tofu links to .COFFEE links (i.e., the Three files but looks at All the files for the search-text).

After the First run(video1), the Second run (video2) shows Reseting the footprint files by changing the Search/Replace text in the Code to search for COFFEE and replace with tofu and I confirmed success by opening in text-editor.

• I changed three Footprints setting them to have Bad Links (bad file types) and confirned they were set to .tofu
• I copied/pasted the Code to the Footprint Folder (this is a MUST)
• I edited the Code to reflect the Path to the Footprint’s sub-folders (the .pretty folders). Note the correct Syntax and saved the file.

Also Note the Search and Replace string/text. You MUST change them to what you want to ‘search for’ and ‘replace with’ (double-clicking the .py Code file should boot your systems default Python editor/IDE). Can also use a Text-Editor in plain-text (not Rich Text)

Then, Run the Code, count to 10 and then enter Caller() into the python console. Count to 15 and check your success.

Note: Counting to 10/15 gives enough time for the process to finish.

Thus, if you see the Red Error Icon in a Path/link… that is the Search-Text you want to Replace. It could simply be the file type or any part of the Path…

Be Careful! Try it on one or two files as shown in video’s. You can also use it/try it on any text-based file…

The Code: Be Sure To Read the Comments in the Code (1.3 KB)

Video 1

Video 2