Billy Huddleston a970235484 CAM: Enhance Path.Command annotations with variant type, type-safe API, and robust persistence
- Refactored `Annotations` member to use `std::variant<std::string, double>` for type-safe storage of both string and numeric values.
- Implemented C++ methods:
	- `setAnnotation(key, value)`: overloaded for string and double types.
	- `getAnnotation(key)`: returns annotation value as string.
	- `getAnnotationString(key)`: returns string annotation.
	- `getAnnotationDouble(key, fallback)`: returns numeric annotation.
	- `getAnnotationValue(key)`: returns raw variant value.
	- `hasAnnotation(key)`: checks for annotation existence.
	- `setAnnotations(annotationString)`: parses and stores values as double if possible, otherwise as string.
- Improved XML serialization (`Save`) and deserialization (`Restore`) to persist annotation types and values, including annotation count for robust restoration.
- Updated Python bindings:
	- `Annotations` property now supports mixed-type values (str/float).
	- Values are returned as native Python types.
	- Type errors are raised for invalid assignments.
- Expanded tests in `TestPathCommandAnnotations.py`:
	- Added cases for mixed-type annotations, edge cases, and in-memory persistence using `dumpContent`/`restoreContent`.
	- Verified type preservation and correct restoration.
- Ensured backward compatibility for string-only annotations and improved error handling.

**How to use annotations in Python:**

```import Path

c = Path.Command('G1', {'X': 10.0, 'Y': 20.0, 'F': 1000.0})
c.Annotations = {
	'tool_name': '6mm_endmill',      # string
	'spindle_speed': 12000.0,        # float
	'feed_rate': 1500,               # int (stored as float)
	'operation': 'pocket',           # string
	'depth_of_cut': -2.5,            # negative float
}
print(c.Annotations)  # {'tool_name': '6mm_endmill', 'spindle_speed': 12000.0, ...}
print(type(c.Annotations['spindle_speed']))  # <class 'float'>
print(type(c.Annotations['tool_name']))      # <class 'str'>

xml = c.dumpContent()
c2 = Path.Command()
c2.restoreContent(xml)
print(c2.Annotations)  # Restored with correct types

c.addAnnotations('speed:1000 operation:drill')
print(c.Annotations['speed'])        # 1000.0 (float)
print(c.Annotations['operation'])    # 'drill' (str)
```
2025-10-15 14:26:13 -04:00
2023-02-13 15:46:28 +01:00
2024-07-14 09:24:22 +02:00
2025-10-06 11:43:26 -05:00

Your own 3D Parametric Modeler

WebsiteDocumentationForumBug trackerGit repositoryBlog

Release Crowdin Liberapay

Overview

  • Freedom to build what you want FreeCAD is an open-source parametric 3D modeler made primarily to design real-life objects of any size. Parametric modeling allows you to easily modify your design by going back into your model history to change its parameters.

  • Create 3D from 2D and back FreeCAD lets you sketch geometry-constrained 2D shapes and use them as a base to build other objects. It contains many components to adjust dimensions or extract design details from 3D models to create high quality production-ready drawings.

  • Designed for your needs FreeCAD is designed to fit a wide range of uses including product design, mechanical engineering and architecture, whether you are a hobbyist, programmer, experienced CAD user, student or teacher.

  • Cross platform FreeCAD runs on Windows, macOS and Linux operating systems.

  • Underlying technology

    • OpenCASCADE A powerful geometry kernel, the most important component of FreeCAD
    • Coin3D library Open Inventor-compliant 3D scene representation model
    • Python FreeCAD offers a broad Python API
    • Qt Graphical user interface built with Qt

Installing

Precompiled packages for stable releases are available for Windows, macOS and Linux on the latest releases page.

On most Linux distributions, FreeCAD is also directly installable from the software center application.

For weekly development releases visit the releases page.

Other options are described on the wiki Download page.

Compiling

FreeCAD requires several dependencies to correctly compile for development and production builds. The following pages contain updated build instructions for their respective platforms:

Reporting Issues

To report an issue please:

  • Consider posting to the Forum, Discord channel, or Reddit to verify the issue;
  • Search the existing issues for potential duplicates;
  • Use the most updated stable or development versions of FreeCAD;
  • Post version info from Help > About FreeCAD > Copy to clipboard;
  • Restart FreeCAD in safe mode Help > Restart in safe mode and try to reproduce the issue again. If the issue is resolved it can be fixed by deleting the FreeCAD config files.
  • Start recording a macro Macro > Macro recording... and repeat all steps. Stop recording after the issue occurs and upload the saved macro or copy the macro code in the issue;
  • Post a Step-By-Step explanation on how to recreate the issue;
  • Upload an example file (FCStd as ZIP file) to demonstrate the problem;

For more details see:

Note

The FPA offers developers the opportunity to apply for a grant to work on projects of their choosing. Check jobs and funding to know more.

Usage & Getting Help

The FreeCAD wiki contains documentation on general FreeCAD usage, Python scripting, and development. View these pages for more information:

The FreeCAD forum is a great place to find help and solve specific problems when learning to use FreeCAD.


This project receives generous infrastructure support from and KiCad Services Corp.

Description
No description provided
Readme LGPL-2.1 7.9 GiB
2026-02-27 16:25:02 +00:00
Languages
C++ 51.5%
Python 45.8%
C 1.3%
CMake 0.8%
NSIS 0.2%
Other 0.2%