GearMaster CAD Module
User Manual — last updated 2026-03-30
The CAD module lets you load 3D geometry files, inspect the assembly structure, toggle visibility of individual components, and save the model state for future use — all without leaving GearMaster.
Two main classes do the work:
| Class | What it does |
|---|---|
GM_CadModel | Loads geometry, stores the assembly tree, computes volume / area / bounding box. |
CadEditor | Opens an interactive 3D window to view and edit the model. |
Quick Start
from GM_modules.Cad import GM_CadModel, CadEditor
model = GM_CadModel()
model.load("my_part.stp") # load a STEP file
editor = CadEditor(model)
editor.show() # open the 3D viewer
To save the model state and reload it later:
model.save("my_part.gmcad") # save as GearMaster native format
# next session:
model2 = GM_CadModel()
model2.load("my_part.gmcad") # fast reload
editor2 = CadEditor(model2)
editor2.show()
STEP files .stp / .step
STEP is the standard 3D exchange format exported by CAD systems like SolidWorks, CATIA, Fusion 360, and FreeCAD. GearMaster reads AP203, AP214, and AP242 variants.
What gets imported
| Feature | Imported? |
|---|---|
| Geometry (faces, edges, vertices) | ✔ Yes |
| Assembly hierarchy (multi-body) | ✔ Yes |
| Named products / components | ⚠ Auto-named by shape type (e.g. Solid_1) |
| Materials, colours, PMI annotations | ✘ Not imported |
Length unit detection
GearMaster reads the unit declaration from the STEP header automatically (millimetres, inches, etc.). The detected unit is shown on the scale bar in the viewer (View → Toggle Scale Bar).
GearMaster native format .gmcad
The .gmcad format is GearMaster's own save format.
It stores the complete model — geometry and state
— so you can pick up exactly where you left off.
What is stored inside
A .gmcad file is a ZIP archive
containing:
| File inside archive | Contents |
|---|---|
manifest.json | Model name, assembly tree, visibility & suppression state, length unit. |
shapes/e001.brep … | Geometry of each solid/shell serialised in OpenCASCADE BRep format (one file per leaf entity). |
.gmcad file is significantly faster than
re-reading the original STEP, because no format conversion is needed.
Use it for frequently opened models.
.gmcad files are specific to GearMaster. They cannot be
opened directly in SolidWorks or other CAD software. Keep the original
STEP file if you need to exchange geometry with external tools.
Recommended workflow
- Export the STEP file from your CAD software.
- Load it once with
model.load("my_part.stp"). - Open the viewer, adjust visibility and suppression as needed.
- Save:
model.save("my_part.gmcad"). - From now on, load
my_part.gmcaddirectly for faster reload and preserved state.
Interface layout
┌───────────────────────────────────────────────────────────────┐ │ File View Help ← menu bar │ ├───────────────┬───────────────────────────────────────────────┤ │ │ │ │ Feature Tree │ 3D Viewport │ │ │ │ │ ▶ Assembly │ (rotate · pan · zoom) │ │ ☑ Solid_1 │ │ │ ☑ Solid_2 │ │ │ ☑ Solid_3 │ │ │ │ │ └───────────────┴───────────────────────────────────────────────┘ │ [ View Mode ] ← mode toolbar └───────────────────────────────────────────────────────────────┘
The window is divided into three areas:
| Area | Description |
|---|---|
| Menu bar | File, View, and Help menus at the top. |
| Feature Tree | Left panel — shows the assembly hierarchy. Click to select; checkbox to show/hide (Edit mode only). |
| 3D Viewport | Right panel — interactive 3D view of the geometry. |
| Mode toolbar | Bottom toolbar — toggles between View and Edit mode. |
Mouse & keyboard controls
Mouse
| Action | Control |
|---|---|
| Rotate view | Left-click and drag |
| Pan (move) view | Middle-click (scroll wheel click) and drag |
| Zoom in / out | Scroll wheel |
| Select entity | Left-click on a solid in the viewport |
| Zoom to fit | Double-click on empty space |
Keyboard
| Key | Action |
|---|---|
| R | Reset camera to fit all geometry |
| F | Zoom to fit selection |
| W | Toggle wireframe / solid display |
| Q | Close the viewer window |
Feature Tree
The Feature Tree on the left lists every component of the assembly in a hierarchical structure matching the STEP file structure.
Selecting an entity
Click on a name in the tree to highlight the corresponding geometry in orange in the viewport. You can also click directly on a solid in the 3D viewport to select it — the tree scrolls to the matching entry automatically.
Showing / hiding (Edit mode only)
In Edit mode, each leaf entity has a checkbox. Unchecking it hides the entity in the viewport. The entity is still included in geometric calculations (volume, bounding box).
Context menu (right-click, Edit mode only)
| Entry | Description |
|---|---|
| Suppress | Deactivates the entity: hidden and excluded from all calculations. |
| Unsuppress | Reactivates a suppressed entity. |
| Suppress children | (Assembly nodes only) Suppresses all solids in the sub-tree. |
| Unsuppress children | (Assembly nodes only) Reactivates all suppressed solids in the sub-tree. |
View mode vs Edit mode
The mode toolbar button at the bottom of the window toggles between the two operating modes:
| View mode (default) | Edit mode ● | |
|---|---|---|
| Camera / display controls | ✔ | ✔ |
| Visible checkboxes in tree | ✘ (read-only) | ✔ |
| Suppress / Unsuppress (context menu) | ✘ | ✔ |
What is an entity?
An entity is a single node in the assembly tree. It can be:
| Type | Description |
|---|---|
| Leaf (solid / shell) | A geometric body that carries actual shape data. Contributes to volume, area, and bounding box. |
| Assembly node | A grouping node with children but no geometry of its own. Used to organise multi-body assemblies. |
Each entity has two independent flags:
| Flag | When False |
|---|---|
shown | Hidden in the viewport, but still counted in volume / bounding box. |
active | Hidden and excluded from all calculations (suppressed). |
Suppress vs Hide: what is the difference?
| Hidden (☐ unchecked) | Suppressed | |
|---|---|---|
| Visible in viewport | No | No |
| Counted in volume | Yes | No |
| Counted in bounding box | Yes | No |
| Tree style | Normal (unchecked) | Grey, strikethrough |
model.save("my_part.gmcad").
Sub-entity selection — overview
The CAD viewport supports contextual sub-entity selection: a single left-click in the 3D scene resolves automatically to the finest geometric element under the cursor — a vertex, an edge, or a face. The selected element is highlighted in orange as a visual overlay on top of the entity mesh.
The selection is held in memory inside the editor and is accessible via the
editor.selection property, which gives you programmatic access to the
underlying OCC geometry objects (TopoDS_Face, TopoDS_Edge,
TopoDS_Vertex). This is the foundation for future operations such as
applying loads and boundary conditions.
| Sub-entity type | OCC object | Typical use |
|---|---|---|
| Face | TopoDS_Face |
Apply distributed loads, fixed constraints, pressure, contact |
| Edge | TopoDS_Edge |
Apply line loads, enforced displacements along a curve |
| Vertex | TopoDS_Vertex |
Apply point loads, pin constraints |
How to select faces, edges, and vertices
Contextual picking logic
Every left-click in the viewport performs a contextual pick: the system queries the distance from the click position to each nearby vertex and edge in screen space and selects the closest element above a threshold.
| Priority | Condition | Result |
|---|---|---|
| 1 (highest) | Click is within 15 pixels of a vertex | Vertex selected |
| 2 | Click is within 10 pixels of an edge | Edge selected |
| 3 (fallback) | Click hits a face surface with no nearby vertex/edge | Face selected |
Single and multi-select
| Action | Result |
|---|---|
| Left-click on a sub-entity | Clear the sub-entity selection and select the clicked face / edge / vertex. |
| Ctrl + Left-click on a sub-entity | Add the clicked item to the existing sub-entity selection. |
| Ctrl + Left-click on an already-selected item | Deselect (toggle) that item. |
| Double-click on an entity | Select the whole entity in the Feature Tree and highlight it orange. Sub-entity selection is not modified. |
| Esc | Clear the entire sub-entity selection and remove all orange highlight overlays. |
Visual feedback
- Face selected: a translucent orange overlay patch is drawn on top of the face triangles.
- Edge selected: an orange thick line (width 4) is drawn along the edge curve.
- Vertex selected: an orange sphere (sized at 1 % of the model bounding-box diagonal) is placed at the vertex coordinates.
editor.clear_selection() is called.
Sub-entity selection — Python API
After the user clicks in the viewport, the selection state is available through the
editor.selection property:
editor = CadEditor(model)
editor.show(blocking=False)
# … user clicks in the viewport …
state = editor.selection # SelectionState object
print(state) # SelectionState(faces=1, edges=0, vertices=0)
# Access selected faces
for face in state.faces:
print(face.entity_id) # e.g. "e003"
print(face.face_index) # 0-based index
occ_face = face.occ_face # TopoDS_Face — usable with pythonOCC
# Access selected edges
for edge in state.edges:
occ_edge = edge.occ_edge # TopoDS_Edge
# Access selected vertices
for vtx in state.vertices:
print(vtx.position) # numpy array [x, y, z]
occ_vtx = vtx.occ_vertex # TopoDS_Vertex
# Programmatic clear
editor.clear_selection()
| Property / Method | Description |
|---|---|
editor.selection |
Returns the current SelectionState. |
editor.clear_selection() |
Clears all selected items and removes the orange overlays. |
state.faces |
List of SelectedFace objects. |
state.edges |
List of SelectedEdge objects. |
state.vertices |
List of SelectedVertex objects. |
state.count() |
Total number of selected sub-entities. |
state.is_empty() |
True when nothing is selected. |
state.all_selected() |
Flat list of all selected items (faces, then edges, then vertices). |
state.clear() |
Clear the state directly (no viewport redraw). |
SelectionState — add / remove programmatically
You can also manipulate the selection state directly from Python without user
interaction. Call the add/remove methods and then editor._window._refresh_selection_overlay()
to redraw.
| Method | Description |
|---|---|
state.add_face(face, multi=False) |
Add a SelectedFace. Clears other items unless multi=True. |
state.add_edge(edge, multi=False) |
Add a SelectedEdge. |
state.add_vertex(vertex, multi=False) |
Add a SelectedVertex. |
state.remove_face(entity_id, face_index) |
Remove a face by entity ID and face index. |
state.remove_edge(entity_id, edge_index) |
Remove an edge by entity ID and edge index. |
state.remove_vertex(entity_id, vertex_index) |
Remove a vertex by entity ID and vertex index. |
Python API quick reference
| Code | Description |
|---|---|
model.load("file.stp") | Load a STEP file. |
model.load("file.gmcad") | Load a GearMaster native file. |
model.save("file.gmcad") | Save current state to .gmcad. |
model.hierarchy | Print the assembly tree as text. |
model.volume | Total volume of all active entities. |
model.surface_area | Total surface area of all active entities. |
model.bounding_box | [[xmin,ymin,zmin],[xmax,ymax,zmax]] numpy array. |
model.length_unit | Unit string, e.g. 'mm'. |
model.get_entity("e002") | Get entity by ID. |
model.find_by_name("gear") | Find entities by partial name match. |
entity.active = False | Suppress an entity programmatically. |
entity.shown = False | Hide an entity programmatically. |
CadEditor(model) | Create the viewer (add mode='edit' for editing). |
editor.show() | Open the viewer window (blocks until closed). |
editor.update_visibility() | Sync viewport after programmatic flag changes. |
editor.selection | Current sub-entity selection (SelectionState). |
editor.clear_selection() | Clear all selected sub-entities. |