Files
make-cad/docs/skill/references/docs/core/README.md
T
NiJingzhe a5e6bf8eb6 feat(core)!: QL-only topology enumeration — remove bare getter list form
Plural topology getters (get_edges/get_faces/get_wires/get_vertices/
get_solids/get_inner_wires/get_edge_occurrences and the Compound
variants) now accept ONLY an index. The no-argument list form raises a
SimpleCADError with migration guidance (enumerate via
ql.<kind>().resolve(shape), pick via get_X(index)). This closes the
selection channel that escapes the graph: Python loops over bare lists
lose the predicate, capture kernel artifacts (the periodic-face seam
edges that broke FCStd translation), and leave no cardinality contract.

- each shape class keeps its enumeration logic as private _iter_<kind>();
  indexed picks record geo-select nodes as before (contract test added);
  Compound getters gain the same indexed recording they lacked
- _TopologySelectionList (the __getitem__ recording vehicle, which also
  made get_X()[i] a silent escape hatch) is retired
- all 109 internal call sites, 165 test call sites, and 31 example call
  sites migrated: SDK/tests use the private channel, user-facing
  examples use ql.<kind>().resolve(...)
- QL _resolve_scope_items switches to the private channel; scene
  contract profile descriptions synced; error strings recommending
  bracket indexing rewritten
- skill docs: strict prohibition added to SKILL.md global rules (new
  rule 6), core README contract statement rewritten, solid/wire/face/
  shell/tagged_mixin pages re-exemplified with QL, geometric-validation
  anti-pattern section updated; mirrors rebuilt via tools/skillbuild.py

Gates: full suite 1418 passed / 5 skipped; translator suites 133 passed;
u_link stage verifiers + render check ALL PASS; scadpkg->FCStd
retranslation verified (5 visible deliverables, 167-object editable
tree).
2026-09-01 02:09:29 +08:00

4.3 KiB

SimpleCAD API Core Classes Documentation

This directory documents the core public object model for SimpleCADAPI.

SimpleCADAPI is OCP-native at runtime: public geometry objects are thin Python wrappers around OpenCascade/OCP shapes exposed through the .wrapped attribute. The package provides functional modeling operations, expression parameters, QL selectors, and replayable model JSON.

Core Classes Overview

Coordinate and tagging utilities

CoordinateSystem

A right-handed 3D coordinate system for local modeling contexts and point/vector transformation.

SimpleWorkplane

A context manager for temporarily modeling in a local coordinate system.

TaggedMixin

Shared tag and metadata behavior for geometry wrappers.

Geometry wrappers

Vertex

A 0D topology wrapper with coordinate queries.

Edge

A 1D topology wrapper for lines, arcs, circles, splines, and other curve edges.

Wire

A connected path made from edges. Wires may be open or closed.

Face

A bounded surface with an outer wire and optional inner wires.

Shell

A connected set of faces that may be open or closed.

Solid

A closed 3D body with volume, faces, edges, tags, and metadata.

Compound

A collection wrapper for multiple geometry objects.

Product semantics roadmap

Part and Assembly Development Plan

Planned single-body Part, material assignment, component placement, and Assembly semantics layered above the current topology/geometry and operation graph model.

Relationship Diagram

TaggedMixin
├── Vertex (0D)
├── Edge (1D)
├── Wire (1D)  ← composed of edges
├── Face (2D)  ← bounded by wires
├── Shell (2D) ← connected set of faces
├── Solid (3D) ← bounded by faces
└── Compound   ← collection of shapes

CoordinateSystem ← independent utility
SimpleWorkplane  ← local modeling context

Design Principles

  • Shape-first API: users work with Vertex, Edge, Wire, Face, Shell, and Solid, not graph nodes.
  • Functional modeling style: public operations return new geometry values, e.g. make_box_rsolid(...), cut_rsolid(...), fillet_rsolid(...).
  • OCP-native runtime: geometry construction, topology traversal, properties, booleans, transforms, and export use OCP/OpenCascade helpers.
  • Replayable graph workflows: an explicit GraphSession records operations, session.capture_result() selects canonical output nodes, and export_model_json() plus replay_model_json() provide interchange and replay.
  • Tags and metadata: tags are useful for lightweight semantics; structured numeric facts should be stored in metadata such as metadata["geo"].
  • QL-only topology enumeration: plural getters such as get_edges(index) and get_faces(index) accept ONLY an index — the no-argument list form is forbidden and raises. Enumerate, count, or measure topology through QL selectors (ql.edges().resolve(shape)); an intentional single pick uses the indexed form, which is recorded as a graph selection node.

Basic Usage

import simplecadapi as scad

with scad.SimpleWorkplane(origin=(0, 0, 0)):
    box = scad.make_box_rsolid(width=5, height=3, depth=2)

scad.apply_tag(shape=box, tag="role.bracket")
box.set_metadata("material", "6061-T6")
box.auto_tag_faces("box")

top_faces = scad.ql.faces().where(scad.ql.tag("face.top")).resolve(box)
print(len(top_faces))

Replayable Model JSON

import simplecadapi as scad
from simplecadapi import GraphSession, export_model_json, replay_model_json

with GraphSession(graph_id="drilled_block") as session:
    body = scad.make_box_rsolid(width=10, height=10, depth=4)
    hole = scad.make_cylinder_rsolid(
        radius=1.5, height=8, bottom_face_center=(0, 0, -2)
    )
    part = scad.cut_rsolid(body, hole)
    session.capture_result(value=part)
    payload = export_model_json(session=session)

rebuilt = replay_model_json(json_str=payload)
print(len(rebuilt))

More Resources