Repository navigation
EN codex docs scan reverse engineering
Русский обзор · English reference
Сеточный scan-to-CAD использует измерения, сечения и редактируемые эскизы для последующего построения твёрдых тел. Облако точек и треугольная сетка — разные виды геометрии: команды сечений и выравнивания сетки не принимают автоматически точечный PLY. Проверяйте масштаб, опорные системы координат, замкнутость профилей и итоговую B-rep-топологию. Сохранение исходных сканов обязательно; правдоподобное изображение не подтверждает метрическую точность или соответствие готовой детали.
Это обзор, не полный перевод. Полные схемы, примеры и подробности контракта приведены на английском ниже.
This contract extends the Document Model v7 scan workflow from reconstructed triangle meshes to editable CAD reconstruction. It does not change the persisted document version: the new operations use existing body, feature, sketch, point, and line objects and the existing OCCT loft/Boolean/fillet pipeline.
For mesh-based reverse engineering, import_scan (workspace PLY) or import_project_scan (staged project PLY) produces a validated cadyx-mesh-v1 triangle mesh using the Open3D CPU bridge (point-cloud reconstruction or triangle-mesh cleanup). A separate import_project_point_cloud command stores a staged point-only PLY as a source-linked point-cloud body without reconstruction. There is no point-count ceiling: CADYX streams all points to validate coordinates, compute full bounds and verify the source SHA-256, while preserving the unchanged full-resolution PLY in the project. The body stores at most 125,000 deterministic sample points for viewport rendering; the browser applies a separate render budget and streams PLY previews. The point-only result is inspectable/renderable but does not supply triangles to align_scan, scan-section extraction or body-to-scan comparison. For those workflows, reconstruct a triangle mesh first. Neither import yields an editable OCCT B-rep; mesh-based reverse-engineering commands create editable sketches that can feed ordinary solid features.
CADYX never infers physical units from PLY coordinates. align_scan records explicit units and a numeric scale supplied by the agent/user. A model built from those scan-derived sketches inherits the resulting coordinate scale by construction; the document schema itself remains unitless.
compare_body_to_scan is a sampled geometric check against tessellated triangles. It is useful for reconstruction iteration, but is not an exhaustive exact B-rep distance proof, metrology certificate, manufacturing tolerance proof, or fit guarantee.
Required: body_id of the original reconstruct_scan body.
Optional parameters:
-
mode:pca(default) orexplicit. -
long_axis:X,Y, orZin PCA mode; defaultYbecause Y-normal XZ stations feedloft_sketchesdirectly. -
basis: three right-handed orthonormal XYZ axis vectors in explicit mode. Each row is a target axis expressed in source coordinates. -
origin: source-space datum. PCA mode defaults to the sampled centroid whencenter=true; explicit mode defaults to[0,0,0]. -
center: PCA-only boolean, defaulttrue. -
axis_signs: three+1/-1values whose product is positive, allowing 180-degree datum flips without mirroring. -
scale: positive coordinate multiplier, default1. -
units:unitless,mm,cm,m, orin; defaultunitless. -
translation: final XYZ translation, default[0,0,0]. -
ground_z: boolean, defaulttrue; after alignment, shifts the scan so its minimum Z is zero. -
name: optional replacement body name.
PCA uses a bounded deterministic sample of mesh vertices, a symmetric 3x3 covariance eigensolve, deterministic axis signs, and a right-handed basis. The command mutates the scan body's current mesh in place so the passive viewport does not show duplicate raw/aligned bodies. The reconstruct_scan feature retains an alignment record and the raw artifact reference. If set_scan_parameter later rebuilds the mesh, the Command System automatically reapplies the stored alignment before the revision is committed.
Re-running align_scan on an already aligned scan reconstructs from the unchanged source SHA-256 first, then applies the new transform. Alignment therefore does not compound numerical transforms.
Required: body_id, finite offset.
Optional:
-
normal_axis:Y(default) orZ. -
join_tolerance: endpoint welding tolerance; default is derived from scan bounds. -
simplify_tolerance: closed-contour RDP tolerance, default0. -
max_points: at least 16 points per contour, default512. Longer loops are arc-length resampled when this value is lower than the source contour's point count. -
max_contours: optional positive count for explicitly limiting generated sketches; omitted means keep every eligible contour. When a limit is supplied, largest enclosed areas are kept first. -
min_area,min_perimeter: non-negative noise filters. -
name: sketch name prefix.
The mesh is intersected triangle-by-triangle with the requested plane. Segment endpoints are tolerance-welded into a graph. Only closed, non-branched components become sketches; open/branched/noise component counts are returned so the agent can adjust the plane or tolerances instead of silently accepting broken profiles.
A Y-normal station becomes an XZ sketch with section_normal_axis="Y" and its exact section_offset. It is immediately compatible with loft_sketches. A Z-normal station becomes an XY sketch. X-normal/YZ authoring is deliberately not faked through the wrong sketch plane; use an explicit re-alignment when a YZ-style station is required until native YZ sketches are added.
Each returned contour includes area, signed area, perimeter, centroid, 2D bounds, point count, and the sketch id. Generated sketches retain their source scan body and section tolerances as provenance metadata.
Batch form of the same operation. offsets contains any number of strictly increasing stations. The command returns:
-
section_groups: one sketch-id list per station, including multi-contour stations; - flattened
sketch_ids; - per-station contour measurements and rejected-component counts.
For Y-normal stations the returned section_groups can be passed directly to loft_sketches. The existing loft implementation already supports one or multiple contours per station, normalizes profile correspondence, and requires strictly increasing section_offset values.
Required: editable non-mesh body_id and scan_body_id.
Optional:
-
max_samples: 64–20000, default4096. -
tolerance: positive threshold in the aligned scan/model coordinate units. -
bidirectional: defaultfalse; when true, also samples body-tessellation vertices against the scan mesh.
The command builds a bounding-volume hierarchy over target triangles and measures sampled point-to-triangle distances. scan_to_body reports sample count, mean, RMS, P95, maximum deviation, and the ten worst sampled points. With tolerance, it also reports the count and percentage within tolerance. Bidirectional mode adds body_to_scan and a sampled two-sided maximum.
Because the B-rep side is evaluated through its current viewport tessellation, the method id is sampled-point-to-tessellated-triangle-bvh-v1. Always report that limitation with the numeric result.
- Import the source with
import_scanand tune reconstruction parameters while preserving the original PLY. - Run
align_scan; keep unitsunitlessuntil scale is known. For elongated parts, map the dominant axis to global Y and keepground_z=trueunless the product datum says otherwise. - Inspect aligned bounds. If a known physical dimension is available, re-run
align_scanwithscale = target_dimension / measured_scan_dimensionand explicitunits. - Create strategically spaced Y-normal stations with
create_scan_sections. Use more stations where curvature, ribs, clips, bosses, or contour topology changes. - Build the principal editable B-rep with
loft_sketches; add local solids/cuts/fillets with existing CADYX commands rather than trying to preserve scan noise as CAD topology. - Run
compare_body_to_scan, inspect P95/max and worst sampled locations, then refine stations/features and repeat. - Inspect the complete final B-rep and viewport, then use
export_brepfor verified STEP/STL delivery when requested.
The reverse-engineering goal is a clean editable design model that matches measured reference geometry within the stated sampled tolerance, not a triangle-for-triangle conversion of scanner noise.