Assembly System
Relevant source files
The following files were used as context for generating this wiki page:
The Assembly System is a core module within Parashell designed to facilitate the creation, management, and solving of mechanical assemblies. It provides the infrastructure to link multiple parts, define their kinematic relationships via joints, and solve these constraints to determine the final placements of components.
The system utilizes a hierarchical structure where assemblies can contain parts, bodies, or sub-assemblies. It integrates a solver to handle geometric constraints and degrees of freedom (DOF), ensuring that components interact realistically within a defined coordinate system.
Sources: src/Mod/Assembly/Gui/Resources/translations/Assembly.ts, src/Mod/Assembly/App/AssemblyObject.cpp
Architecture and Core Components
The Assembly System is built on several key classes that manage different aspects of the assembly lifecycle, from data storage to constraint solving.
AssemblyObject
The AssemblyObject serves as the primary container for an assembly. It manages the collection of components and the joints that connect them. It is responsible for triggering the solver and updating the state of the assembly when changes occur.
JointGroup
A JointGroup is an organizational container within an assembly that holds related mechanical joints. This allows users to categorize or group constraints for better management within the document tree.
AssemblyLink
The AssemblyLink class provides the mechanism for creating dynamic links to external or internal parts, bodies, and sub-assemblies. It allows a sub-assembly to be treated as either a rigid unit or a flexible component where internal joints are respected by the parent assembly solver.
Sources: src/Mod/Assembly/App/AssemblyObject.cpp:1-50, src/Mod/Assembly/App/JointGroup.cpp:1-40, src/Mod/Assembly/App/AssemblyLink.cpp:1-30, src/Mod/Assembly/Gui/Resources/translations/Assembly.ts
Component Relationship Diagram
The following diagram illustrates the relationship between core assembly components.
The diagram shows that an AssemblyObject contains multiple JointGroups and AssemblyLinks. JointGroups organize individual JointObjects, while AssemblyLinks connect external parts or sub-assemblies.
Sources: src/Mod/Assembly/App/AssemblyObject.cpp, src/Mod/Assembly/App/JointGroup.cpp, src/Mod/Assembly/App/AssemblyLink.cpp
Joint Types and Constraints
The system supports a variety of joint types to define how parts move relative to each other. Joints are defined by selecting two elements (references) from separate parts.
| Joint Type | Description |
|---|---|
| Fixed | Permanently locks two parts together, preventing all movement and rotation. |
| Revolute | Allows rotation around a single axis between parts. |
| Cylindrical | Allows both rotation and translation along a single axis. |
| Slider | Restricts movement to linear translation along one axis. |
| Ball | Connects parts at a point, allowing free rotation around that point. |
| Distance | Fixes the distance between two selected objects or faces. |
| Parallel | Forces the Z-axes of two coordinate systems to remain parallel. |
| Perpendicular | Forces the Z-axes of two coordinate systems to remain perpendicular. |
| Rack and Pinion | Links a sliding part to a rotating part with a defined movement ratio. |
| Gears/Belt | Links two rotating parts together with specified radii or gear ratios. |
Sources: src/Mod/Assembly/Gui/Resources/translations/Assembly.ts, src/Mod/Assembly/App/AssemblyUtils.cpp
Solving and Degree of Freedom (DOF) Analysis
The system includes a solver that calculates the position of all parts based on the defined joints. It also provides feedback on the constraint status of the assembly.
Solver Logic
The solver processes the assembly to determine if it is:
- Fully constrained: No remaining degrees of freedom.
- Under-constrained: Parts can still move; the solver reports the remaining degrees of freedom.
- Over-constrained: Conflicting joints prevent a valid solution.
- Redundant: Some joints provide constraints that are already satisfied by other joints.
DOF Reporting
When an assembly is solved, the system updates the ViewProvider to show the number of Degrees of Freedom. For unconstrained components, the system identifies the specific parts contributing to the DOF.
Sources: src/Mod/Assembly/App/AssemblyObject.cpp:100-200, src/Mod/Assembly/Gui/Resources/translations/Assembly.ts
Solve Sequence Diagram
This diagram describes the interaction between the user interface, the assembly object, and the solver.
The solver consumes constraint data prepared by utility functions and returns calculated placements for the parts involved.
Sources: src/Mod/Assembly/App/AssemblyObject.cpp, src/Mod/Assembly/App/AssemblyUtils.cpp
Bill of Materials (BOM) System
The BomObject is responsible for generating a Bill of Materials for the assembly. It is implemented as a spreadsheet-compatible object that automatically populates based on the assembly structure.
Features
- Automatic Population: Columns like Index, Name, File Name, and Quantity are populated automatically during recompute.
- Filtering Options:
- Include sub-assembly children: Decides if children of nested assemblies are listed individually.
- Only parts: Excludes solid bodies (like fasteners or primitives) to show only top-level part containers.
- Customization: Users can add custom columns (e.g., Description) that are not overwritten during automatic updates.
Sources: src/Mod/Assembly/App/BomObject.cpp:50-150, src/Mod/Assembly/Gui/Resources/translations/Assembly.ts
Assembly Utilities
The AssemblyUtils file contains helper functions used across the module for geometric calculations and object management.
- Coordinate Systems: Functions to retrieve or calculate local coordinate systems for joint markers.
- Object Traversal: Utilities to iterate through the assembly hierarchy to find parts, links, or joints.
- Selection Helpers: Logic to ensure users select valid elements (e.g., two elements from two different parts) when creating joints.
Sources: src/Mod/Assembly/App/AssemblyUtils.cpp
Summary
The Parashell Assembly System provides a robust framework for managing complex mechanical relationships. By utilizing AssemblyObject for containment, AssemblyLink for modularity, and a specialized solver for constraint resolution, the system allows for the creation of functional digital prototypes. Features like DOF analysis and the automatic BOM system further integrate mechanical design with manufacturing documentation requirements.