BCad fork

Standard libraries and the include/use search path
Login

Standard libraries and the include/use search path

The <...> form of use / include resolves against an ordered search path, so built-in (bundled) libraries are referenced by bare name and never depend on where bCAD is actually installed.

Resolution order

  1. directory of the file containing the directive (a local file of the same name wins — tests keep using use <lib/testing.scad>);
  2. user library directories from settings.conf:

   [general]
   library_path = /home/user/scad_libs:/opt/team_libs

Separator is os.pathsep (: POSIX, ; Windows) or a comma. ⚠ the OCCT worker reads settings.conf on startup, so change the path and restart (or open the worker again) before rendering.

  1. bundled standard libraries — bcad/assets/libraries/. The directory is resolved from __file__, so it works for any install layout (dev tree, AppImage, Windows build).

Absolute paths resolve as-is; nested use/include inside a library file are anchored to that library's own directory.

Implementation

bcad/binterpreter/library_paths.py is the single source of truth:

Used by scl.py (_expand_scope include flattening, use and include handlers) and the editor's Ctrl+E jump (bcode_editor.py). import() / surface() stay strictly file-relative (search_libraries=False), keeping OpenSCAD semantics while still guarding the unsaved-buffer case.

Bundled libraries

bcad/assets/libraries/ ships with the app (see its README). Drop .scad files there — or in a subdirectory referenced as use <MCAD/…> — and they become available globally. Test: tests/library_search.scad covers bundled resolution and nested use inside a bundled library.