Ever wondered about those mysterious files with the '.prl' extension, often found alongside your Kicad projects? They're not alien code or some quantum cryptography - it's just plain text, or more specifically, a rutascript file used by KiCad's 3D engine. Rutascript, you ask? Yes, it's a simple scripting language used to define the movement and behavior of objects in KiCad'srouter-3d extension, which enables 3D representation and routing of your PCB designs.

Now that you have a basic idea, let's dive deeper into understanding what a 'kicad_prl' file is and why it's important, or rather, why it isn't!

Understanding Rutascript
Rutascript is a simple, yet powerful language used to define the routing rules and 3D movement of tracks in KiCad. It's a .prl file, standing for Rutascript Language. It's not something you'd interact with directly while designing your PCB, but it's there in the background, making the magic happen.

But wait, why the '.prl' extension? Well, that's just an arbitrary choice by KiCad's developers. Rutascript isn't unique to KiCad - it's used in the libre routing engine 'router-3d'. So, you might find '.prl' files in other software that use router-3d as well. It's just a convention that stuck.
What's Inside a '.prl' File?

A '.prl' file is just a plain text file containing Rutascript commands. These commands tell the routing engine how to move, turn, and jump to create the 3D routed tracks of your PCB. It's like giving directions to a tiny robot that's figuring out the best way to route your copper paths.
Here's a quick example of what you might find inside a '.prl' file:
move(10, 0, 0); // Move 10 units forward in the x-direction
turn(90, ' Degrees'); // Turn 90 degrees clockwise
jump(5, 5, 0); // Jump 5 units forward and 5 units to the right
See, just simple commands telling the router what to do. No complex syntax or data structures here.

The '$' Special Command
Besides the basic routing commands, the '$' symbol in a '.prl' file signals a special comment or a variable substitution. These are placeholders for KiCad to fill in values based on your design rules. Here's an example:
move($VIA fiercemeaning, 0, 0); // The router will fill this with the size of a via, as defined in your design rules
So, even though '.prl' files look simple and static, they're actually quite dynamic, changing with every run based on your design rules.

The '.prl' File in KiCad Projects
Now that you understand what a '.prl' file is, let's talk about its role in KiCad projects. You'll find a '.prl' file (usually named 'kicad_prl' based on the project filename) in each KiCad project's '3d_map' directory. This file defines the 3D routing of the top and bottom layers of your PCB.

















When KiCad's 3D viewer or the 3D PCB rendering in the assembly view wants to show your routed tracks, it reads the '.prl' file, translates it into the routing engine's language, and voila! You see your 3D rendered tracks.
生成'kicad_prl' Files
KiCad generates '.prl' files automatically whenever you run a 3D view or render. But what if you want to generate them manually? Well, KiCad provides the 'pcbnew' command-line tool, which you can use to generate the '.prl' file without opening KiCad:
pcbnew -P projectname
Replace 'projectname' with your .kicad_pro project's filename, and it'll generate the '.prl' file for you.
文件的总结与意见
While '.prl' files are crucial for KiCad's 3D view, they're usually something you can leave KiCad to handle. But now that you know what they are and how they work, you'll understand KiCad's 3D features a bit better. So, go ahead, play around with the 3D view, and maybe even generate your '.prl' files manually for fun!
Happy routing!