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:

ClassWhat it does
GM_CadModelLoads geometry, stores the assembly tree, computes volume / area / bounding box.
CadEditorOpens 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.

Read-only GearMaster never writes back to STEP files. The original file is always preserved exactly as exported from your CAD system.

What gets imported

FeatureImported?
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 archiveContents
manifest.jsonModel 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).
Tip Reloading a .gmcad file is significantly faster than re-reading the original STEP, because no format conversion is needed. Use it for frequently opened models.
Compatibility .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

📐 my_part.stp
🐍 model.load()
🖥️ CadEditor
💾 model.save()
📦 my_part.gmcad
  1. Export the STEP file from your CAD software.
  2. Load it once with model.load("my_part.stp").
  3. Open the viewer, adjust visibility and suppression as needed.
  4. Save: model.save("my_part.gmcad").
  5. From now on, load my_part.gmcad directly 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:

AreaDescription
Menu barFile, View, and Help menus at the top.
Feature TreeLeft panel — shows the assembly hierarchy. Click to select; checkbox to show/hide (Edit mode only).
3D ViewportRight panel — interactive 3D view of the geometry.
Mode toolbarBottom toolbar — toggles between View and Edit mode.

Mouse & keyboard controls

Mouse

ActionControl
Rotate viewLeft-click and drag
Pan (move) viewMiddle-click (scroll wheel click) and drag
Zoom in / outScroll wheel
Select entityLeft-click on a solid in the viewport
Zoom to fitDouble-click on empty space

Keyboard

KeyAction
RReset camera to fit all geometry
FZoom to fit selection
WToggle wireframe / solid display
QClose the viewer window
Note Keyboard shortcuts are provided by the underlying VTK/PyVista layer and work when the 3D viewport has keyboard focus (click inside it first).

File menu

EntryAction
CloseCloses the viewer window. The model remains loaded in memory.

View menu

EntryDescription
Reset CameraFit all visible geometry into the viewport.
Toggle WireframeSwitch between solid surface and wireframe display.
Toggle OrthographicSwitch between perspective (default) and orthographic projection. Useful for measuring.
Toggle EdgesShow or hide the mesh edges on the surface.
Toggle Ambient OcclusionEnable/disable Screen-Space Ambient Occlusion (SSAO) for a more realistic shading under concavities.
Toggle Origin AxesShow/hide the XYZ coordinate axes at the world origin.
Toggle Scale BarShow/hide a linear scale ruler in the scene. The label uses the length unit stored in the file.
Standard Views → Top / Front / Right / IsometricJump to a standard camera orientation.
Show AllMake all entities visible.
Hide AllHide all entities.
Expand Tree / Collapse TreeExpand or collapse all nodes in the Feature Tree.

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)

EntryDescription
SuppressDeactivates the entity: hidden and excluded from all calculations.
UnsuppressReactivates 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)
Tip Start in View mode for safe exploration. Switch to Edit mode only when you want to modify the assembly state.

What is an entity?

An entity is a single node in the assembly tree. It can be:

TypeDescription
Leaf (solid / shell)A geometric body that carries actual shape data. Contributes to volume, area, and bounding box.
Assembly nodeA grouping node with children but no geometry of its own. Used to organise multi-body assemblies.

Each entity has two independent flags:

FlagWhen False
shownHidden in the viewport, but still counted in volume / bounding box.
activeHidden and excluded from all calculations (suppressed).

Suppress vs Hide: what is the difference?

Hidden (☐ unchecked)Suppressed
Visible in viewportNoNo
Counted in volumeYesNo
Counted in bounding boxYesNo
Tree styleNormal (unchecked)Grey, strikethrough
Remember Changes to visibility and suppression are stored only in memory. To keep them across sessions, save the model: 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 typeOCC objectTypical 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.

PriorityConditionResult
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
Tip — If you want to select a face but keep picking a nearby edge, zoom in (scroll wheel) to increase the pixel distance between the two elements.

Single and multi-select

ActionResult
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.
Note — Sub-entity selection overlays are drawn on top of the entity mesh. They do not affect the model geometry and are cleared when the window is reopened or when 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 / MethodDescription
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.

MethodDescription
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

CodeDescription
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.hierarchyPrint the assembly tree as text.
model.volumeTotal volume of all active entities.
model.surface_areaTotal surface area of all active entities.
model.bounding_box[[xmin,ymin,zmin],[xmax,ymax,zmax]] numpy array.
model.length_unitUnit 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 = FalseSuppress an entity programmatically.
entity.shown = FalseHide 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.selectionCurrent sub-entity selection (SelectionState).
editor.clear_selection()Clear all selected sub-entities.