clean-similar-objects
Dedup the currently selected NON-CURVE objects. Sibling to clean-similar-curves (curves) and
clean-geometry (curve cleanup). One script next to this file, simobj_diagnose.py, invoked by the
usual one-line loader. v1 is REPORT-ONLY — it never deletes; it reports groups and stashes a plan
in sc.sticky["simobj_plan"] for a future v2 apply.
What it detects
- COINCIDENT duplicates — same shape (topology counts + bbox extents) AND same place (bbox
center within
CEN_TOL). This is the paste-in-place / stacked case → keep one. Type-agnostic: a Brep and an Extrusion of the same solid match (extrusions are compared via.ToBrep()). - CONGRUENT copies — same shape/size but a DIFFERENT place. Reported separately because they are usually intentional copies (repeated members) — for the user to eyeball, not auto-delete.
- Kinds handled: Breps + Extrusions (as breps), Meshes (vertex/face counts + bbox), block instances
(same
InstanceDefinition+ same instance transform = stacked block).
Procedure
- Resolve path. Glob
**/clean-similar-objects/simobj_diagnose.py. Do NOT hardcode. - Diagnose (non-destructive).
Prints counts per kind: coincident duplicate groups (+ removable count = keep 1 each) and congruent groups. Changes nothing.exec(open(r"<ABS>\simobj_diagnose.py").read()) - Report to the user. v1 stops here (report-only). If the user wants deletion now, do it explicitly and per-item with confirmation (there is no bulk apply script yet).
Gotchas (baked in)
- Cheap fingerprint by design. Uses topology counts + bbox extents + bbox center — NOT
VolumeMassProperties/AreaMassProperties, which timed out on a real 340-brep / 2000-block model. Volume/centroid confirmation is a v2 refinement (add it only for the delete step, on the small candidate set, never on the whole selection). - Selection excludes locked/hidden.
_SelAll/Objects.Selectskip objects on locked or hidden layers, so the diagnose sees only the selectable subset (e.g. 573 of 2338 on the test model). That's correct for a selection-based skill — unlock/show layers first if you mean to include them. - Coincident vs congruent split prevents nuking legitimate arrays: only same-place stacks are "duplicates"; moved copies are flagged for review, never counted as removable.
- Blocks compared by definition index + instance transform, never by exploded geometry.
Not yet implemented (deferred to v2, by user decision)
- Apply / delete. v1 reports only. v2: delete coincident duplicates (keep 1) after confirm, with a
volume+centroid or
GeometryEquals/closest-point equivalence check before each delete (never delete on the cheap fingerprint alone). - Partial-overlap solids → 3-chunk boolean split (
CreateBooleanDifferenceA−B / B−A +CreateBooleanIntersectionA∩B) with the boolean guardrails:SolidOrientation/Flip,SplitKinkyFaces, null-vs-empty, validateIsValid/IsSolid. See the plan. - Congruent (moved) auto-dedup — left as report-only (usually intentional).
Reference
Built 2026-07-01 (task 1b of the 6-task suite). Diagnose validated on the live production model
260629 main ms.3dm (50 breps/extrusions + 523 blocks selectable → 0 coincident, 4 congruent brep
groups, no false positives). See memory rhino-clean-rhino-method and the plan.