Per-project environment variables?

hi all,
I’m trying to structure a project such that it can be easily moved between (Linux) hosts with varying ‘projects’ root directories. All personal or project specific libraries are below this root directory.
For symbols and footprints this easy to achieve, using library paths relative to ${KIPRJMOD}.
I’m struggling to find a good solution for 3d models though.

I’ve read through Is it possible to have a 3D model, relative path to custom footprint?, hopefully having understood most of the discussion. So for the time being, I’m using a personal environment variable to define the path to ‘my’ 3d lib, which works fine.
However, with different ‘projects’ roots, this environment variable would need to be different as well.

So here’s the question: is there an easy way to define environment variable as part of the project? As far as I can see, they are stored by default as part of the user specific kicad data (~/.config/kicad/kicad_common) in my installation.

thanks for any comments -
Karsten

If you already have the footprints specialized to the project then use KIPRJMOD in the 3d model path as well.
Something like this:

1 Like

@Rene_Poschl - thanks for the quick reply.

I understand this will work just fine, however I was hoping for a project global setting by just setting a common environment variable for the path, which in my case would be sth. like${KIPRJMOD}/…/…/…/my_libs/my_3d_lib. So I was looking for some simplification by defining a project specific env. variable.

Actually this variable would not even need to be project specific as long as my projects all follow the same directory structure. In principle it could be specified globally (i.e. per user). The problem with this is that obviously the global environment variables handling does not expand ${KIPRJMOD}.

best regards -
Karsten

1 Like

Nothing is stopping you from creating your own variables in the Configure Paths... window.

You can set it up like I did with individual variables for symbols, footprints, 3D objects, and templates (I use a custom page frame). Then access them like ${USER_SYMBOLS)/, ${USER_MODS)/, ${USER_3DMODS)/, etc.

Or use a single user variable for the parent path where all the folders for symbols, footprints, 3D objects, etc. reside and access them like ${USER_LIBRARY)/Symbols, ${USER_LIBRARY)/Modules, ${USER_LIBRARY)/3DModules, etc. Or how ever you want to name them.

When distributing the project you just need to make sure that the recipients know how the paths are configured and what the expected variable names are.

@kdf_kicad, the concept of “project portability” seems to come up every month or two. As far as I know, there is no simple way to create a self-contained archive that includes all of the symbols, footprints, schematics, and layout files for a given project - and which can be opened on any machine running a current version of KiCAD.

Dale

To be more specific: There is no automatic click one button way to do it.

There are ways to get the requested result with a bit of effort. I described one above. (The 3d model side of it) For it to work you would need to manage project libraries. (You can setup your own personal global libs in such a way that your reduce the work needed.)

In addition, the footprints do not really need to be in project libs. They are after all part of the pcb_new file. This means you only need to copy a few files into the project directory if you setup the 3d path in the library as i suggest above and the layout/3d side is fully portable.

And with the cache lib and rescue functionality you can even kind of say that the schematic is also portable. (This is a bit more sketchy as the rescue stuff is not as reliable as one would wish)

1 Like

Actually, @MitjaN has an archive script that may work (not sure if it works in 5.0.1, I haven’t tested) in his github repository for collecting and remapping all the bits used in a project to the project folder, including 3d objects. But IMHO its results are best for finished project distribution. For collaborative working (either as a team, or one person using several machines to access the same design), it is probably best to make sure the path variables are all configured appropriately for personal/team global libraries.

Working on a project would require a full library setup anyways. As it is expected that one would need to add things to the project. (Adding a capacitor here or there can happen at every stage of the project) Including the stuff that is already in a project in project local libs will not help out with that.

thank you all for your hints!
I see there are several ways to configure the project such that it can be worked on from different computers - just not the one I was hoping for :wink:
To summarize from my understanding:

  • for symbols and footprints, the situation is best
  • for the 3d models the options are a little less intuitive, but still feasible.

Anyway, as Rene has mentioned - the 3d models are not really essential

best regards -
Karsten

On Windows, I use “mklink /J” to map project folders into the global 3d models so I don’t have to use environment variables (linux “ln” do similar effect).
But still, there are addition, manual step in either ways. I hope once day, KiCad search 3D models through a list of paths, just like the PYTHONPATH, or PATH environment works. With some automatic pre-appending path in like: 3D global path; footprint path, project path;

Thanks for the PR. As the script can run in standalone mode, it could be run as a pre-commit hook, if the project is shared between collaborators via SCM tool.

Regarding the 3D models, KiCad 5.1 has a patch so that one can read/change 3D model settings from python interface, so this opens a few options for automating custom solutions.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.