CAM ToolBit Library

Description

Within the CAM Tools system, Tool Bits are organized into libraries. A library is simply a list of Tool Bits and can be used by the user for whichever purpose is needed. A Tool Library is nevertheless a great representation for a physical grouping of tools, such as in an automatic tool changer. Or tools might be grouped by intended use, for example all tools for cutting plastic.

A Tool Library is a JSON file (.fctl) in the Tools/Library folder of the asset directory. It maps tool numbers to Tool Bit IDs; the Tool Bits themselves live in Tools/Bit. As a consequence each Tool Bit can be in multiple libraries.

introduced in 1.1: libraries are stored in the asset directory and edited with the rewritten Library Manager; drag and drop and copy/paste between libraries were added.

FreeCAD ships one library, Default, with 13 Tool Bits (3.175 mm and 5 mm endmills, 5 mm drill, 6 mm ball end, 6 mm bullnose, 30/45/60/90 degree V-bits, 45 degree chamfer, slitting saw, probe, 5 mm thread cutter). It is copied into the asset directory the first time the Library Manager or Toolbit Selector is opened.

Tool numbers

A Tool Bit has a permanent ID (its file name, shown as ToolBitID). The tool number, however, belongs to the library: the same Tool Bit can have different numbers in different libraries. Numbers are unique within a library; giving a Tool Bit a number that is already in use moves the other Tool Bit to the next free number. When a Tool Controller is created from a library entry, the library number becomes the Tool Controller’s Tool Number, which can be changed afterwards.

Usage

Libraries are managed in the Library Manager (CAM  Toolbit Library Manager):

  • Adds a new library: opens the Library Properties dialog asking for a Name.

  • Renames the library (also F2 in the library list).

  • Removes the library (also Del); the Tool Bits it lists are kept on disk.

  • Imports a library from a .fctl or Camotics .json file; Tool Bits referenced by an imported file are imported from the Bit folder next to it if they are not yet in the asset directory.

  • Exports the library as .fctl, Camotics .json or LinuxCNC tool table .tbl.

Tool Bits are added to a library with Adds a toolbit (new Tool Bit), Imports a toolbit (.fctb or YAML file), copy/cut/paste between libraries, or by dragging Tool Bits from the list onto a library in the left pane. The pseudo-library All Toolbits lists every Tool Bit in the asset directory regardless of library membership.

The library last selected in the Library Manager or Toolbit Selector and the last sort order are remembered between sessions (parameters LastToolLibrary and LastToolLibrarySortKey under Preferences/Mod/CAM/Tools). Changing the asset path resets the remembered library.

Export

A library can be exported with Exports the library in the Library Manager as:

  • FreeCAD Tool Library (.fctl),

  • Camotics tool table (.json),

  • LinuxCNC Tool Table (.tbl): one line per tool, T<number> P0 X0 Y0 Z0 A0 B0 C0 U0 V0 W0 D<diameter> I0 J0 Q0 ;<label>, with the diameter in the user’s preferred length unit and the number of decimals from the unit preferences. introduced in 1.1

JSON Structure

{
  "label": "Default",
  "tools": [
    {
      "nr": 1,
      "path": "3.175mm_Endmill.fctb"
    },
    {
      "nr": 2,
      "path": "5mm_Endmill.fctb"
    }
  ],
  "version": 1
}

The label is the name shown in the UI; if missing, the file name is used. Each path is the ID of a Tool Bit in Tools/Bit.

Scripting

from Path.Tool.camassets import cam_assets

lib = cam_assets.get("toolbitlibrary://Default", depth=1)
for bit in lib:
    print(lib.get_bit_no_from_bit(bit), bit.label)
lib.add_bit(bit, bit_no=20)
cam_assets.add(lib)  # save