Part & PartDesign Workbenches
Relevant source files
The following files were used as context for generating this wiki page:
- src/Mod/PartDesign/App/Body.cpp
- src/Mod/PartDesign/App/Feature.cpp
- src/Mod/PartDesign/Gui/Resources/translations/PartDesign.ts
- src/Mod/PartDesign/Gui/Resources/translations/PartDesign_af.ts
- src/Mod/PartDesign/Gui/Resources/translations/PartDesign_fi.ts
- src/Mod/PartDesign/Gui/Resources/translations/PartDesign_ms.ts
The PartDesign Workbench provides a modern, feature-based parametric modeling workflow for creating complex solid parts. Unlike the traditional constructive solid geometry (CSG) approach, it centers around the concept of a Body, which acts as a container for a cumulative sequence of additive and subtractive features that determine the final shape of a single solid.
The architecture relies on a "Tip" system where the current state of a model is defined by a specific feature in the history tree. This enables users to move the active modeling point, insert new operations, and manage dependencies within a unified coordinate system.
Sources: PartDesign_ms.ts, Body.cpp:45-60
Core Architecture: The Body Container
The PartDesign::Body is the fundamental organizational unit. It manages a list of features and ensures they result in a single contiguous solid. A Body maintains its own local coordinate system and a "Tip" pointer, which marks the latest valid feature in the modeling sequence.
Key Components of a Body
- Group: A list of features that belong to the body.
- Tip: A reference to the feature that currently represents the complete solid.
- Base Feature: An optional external geometry used as the starting point for the modeling process.
The diagram shows the relationship between the Body container and the individual features that define the solid's geometry.
Sources: Body.cpp:65-90, PartDesign_ms.ts
Feature Classification
Features in PartDesign are categorized based on how they contribute to the solid. They are typically based on 2D sketches or primitive geometric shapes.
Additive and Subtractive Operations
- Additive Features: These add volume to the solid (e.g., Pads, Revolutions, Additive Primitives).
- Subtractive Features: These remove volume from the solid (e.g., Pockets, Grooves, Holes, Subtractive Primitives).
| Feature Category | Examples | Purpose |
|---|---|---|
| Sketch-Based | Pad, Pocket, Revolution, Groove | Extrudes or revolves 2D profiles into 3D. |
| Primitives | Box, Cylinder, Sphere, Cone | Adds or subtracts predefined 3D shapes. |
| Dress-Up | Fillet, Chamfer, Thickness, Draft | Modifies existing edges or faces without creating new base geometry. |
| Transformation | Mirror, Linear Pattern, Polar Pattern | Duplicates existing features across axes or patterns. |
Sources: PartDesign.ts, PartDesign_af.ts, PartDesign_fi.ts
Modeling Logic and Data Flow
Modeling in PartDesign follows a strict sequential flow. Each feature (except the first) requires a previous valid shape to operate on. The execute() method of a feature retrieves the shape from its predecessor, applies its specific transformation (e.g., a pocket removes material), and passes the result forward.
Sequential Recomputation Flow
This flow illustrates how volume is cumulatively modified until it reaches the designated Tip feature.
Sources: Feature.cpp:45-55, Body.cpp:400-420
Recomputation and Error Handling
The workbench enforces single-solid consistency. If an operation results in multiple disconnected solids, the system raises an exception unless the Allow Compound property is enabled on the Body. Common errors handled during execution include:
- Empty Shapes: Occurs if a sketch has no valid wires.
- Dependency Violations: Occurs if an earlier feature attempts to depend on a later one in the history.
- Fusion Failures: Occurs when additive features do not touch the existing solid.
Sources: PartDesign_ms.ts:Exception, Body.cpp:1168-1175
Specialized Tools
Datum Entities
Datum tools provide reference geometry that is not part of the solid itself but is used for positioning sketches and features.
- Datum Plane: Used as a mapping target for sketches.
- Datum Line: Used as a rotation axis for grooves or revolutions.
- Datum Point: Used for precise vertex referencing.
Shape Binder
The Shape Binder and Sub-Shape Binder allow referencing geometry from different Bodies or even external documents. This enables multi-body modeling where one part can adapt to changes in another.
Sources: PartDesign.ts:CmdPartDesignSubShapeBinder, PartDesign_af.ts:CmdPartDesignShapeBinder
Summary
The Part & PartDesign workbenches implement a sophisticated parametric engine that manages the lifecycle of a single solid. By encapsulating modeling operations within a Body and utilizing a "Tip" system, the workbench ensures that complex geometric histories remain editable, predictable, and robust.
Sources: Body.cpp, Feature.cpp