Repository navigation
Adds Geometry Cleanup settings with a tolerance for each error type - #3618
Merged
HakanSeven12 merged 2 commits intoNov 24, 2026
Merged
Conversation
A Settings button in the Geometry Cleanup palette opens the Geometry Cleanup Settings dialog, as in AutoCAD 2027. It sets the error types to find and a tolerance for each, shows the proposed tolerance, and imports and exports AutoCAD .gcs files. Scan saves the settings in the user profile, closes the dialog and scans. Until the user saves settings, each drawing uses its proposed tolerance, as before. The scan holds each candidate to the tolerance of its own type before it picks the nearest error of each end. The angle rows of a .gcs file are kept and written back, but not used yet. Co-Authored-By: Claude
Tests a tolerance for each error type in the scan, the gap corner held to the gap tolerance, the .gcs file with a file from AutoCAD 2027, the settings in the user profile, and the Settings dialog: Scan, Cancel, Import, Export, removed and added types, values that cannot be kept, and a scan from another drawing tab. Also corrects the proposed tolerance in the comment of the test drawing (0.5198, not 0.64). Co-Authored-By: Claude
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Change summary
Adds the Geometry Cleanup Settings dialog, as in AutoCAD 2027: the error types to find, a tolerance for each, the proposed tolerance, and Import and Export of
.gcssettings files. The settings are kept in the user profile and apply to all drawings.This is the second pull request for Geometry Cleanup, after #3603.
What specifically changed
crates/ocs_geom/src/geom2d/cleanup.rs:end_errorstakes a tolerance for each error type (Tolerances;Nonefor a type that is not scanned). The search reaches as far as the largest tolerance, and each candidate is held to the tolerance of its own type before the nearest error of each end is picked. (A filter after the pick would lose errors: an end with a 0.5 gap and a 0.6 undershoot, with a gap tolerance of 0.2, would report nothing.)src/modules/manage/geometry_cleanup_settings.rs: the settings, in the form of a.gcsfile:{"tolerances": [{"name": "gap", "subName": "", "tolerance": 0.4}, ...]}. A type that is not in the list is not scanned. A tolerance less than 0.0001 becomes 0.0001, and a tolerance has at most 6 decimals. The angle types (absolute-angle,relative-angle) are kept and written back, but not shown or scanned until the angle errors come.src/ui/window/geometry_cleanup_settings.rs: the dialog. Import settings (the file and Browse), a row for each error type with its tolerance, the proposed tolerance (a click puts it in the box) and ✕ (remove), "Add error type" for a removed type, and Cancel, Export and Scan (Rescan after the first scan). Scan and Export are disabled while a box does not hold a number.src/ui/window/geometry_cleanup.rs: a Settings button in the palette toolbar. Each type's category bar shows its tolerance ("Gap: 3 (0.4)") in place of the one "Tolerance:" line.src/app/commands/geometry_cleanup.rs: the dialog's messages. Scan saves the settings, closes the dialog and scans: the objects of the palette's scan again, or all the supported objects in model space when the palette has no scan of the drawing.src/app/config.rs:geometry_cleanup, the saved settings.Noneuntil the user saves settings; each drawing then uses its proposed tolerance, as before.src/app/commands/geometry_cleanup_tests.rs: corrects a comment from Adds Geometry Cleanup to find and fix ends that almost meet #3603. The proposed tolerance of the test drawing is 0.5198 (1% of a mean length of 51.98), not 0.64.src/locale_catalog.rsand in every locale (with the English text); the label "Tolerance: {}" is removed.Why
AutoCAD's Geometry Cleanup has this dialog, and #3603 had none: it used the proposed tolerance for all three types.
The
.gcsformat is not published. This pull request reads and writes the format of a file exported from AutoCAD 2027, and its tests use that file's text. That a removed type is left out of the file is this pull request's reading of the format: the file has no other place for it.A
.gcsfile that cannot be read (not JSON, notolerances, a negative tolerance, a tolerance too large to keep) gives an error on the command line and changes nothing. In the user profile, Geometry Cleanup settings that cannot be read are dropped; the rest of the profile loads as before.Testing
crates/ocs_geom/src/geom2d/cleanup.rs(3 new tests): a type with no tolerance is not reported; each type uses its own tolerance (the case above); the corner of a gap is held to the gap tolerance.src/modules/manage/geometry_cleanup_settings/tests.rs(8 tests): AutoCAD's file gives its tolerances and keeps its angle rows; a file written and read again is the same; a type left out of the file is not scanned; files that cannot be used are errors; the minimum tolerance (also for a tolerance of 0) and the 6 decimals; a tolerance too large to keep is an error; a type added back goes before the angle rows.src/app/commands/geometry_cleanup_tests.rs(18 new tests): the settings are kept in the user profile, a profile from before has none, and settings in the profile that cannot be read are dropped without the rest of the profile; the proposed tolerance has at most 6 decimals; a scan uses the saved tolerance of each type, and the proposed one when none is saved; the dialog opens with the proposed tolerances; Scan saves and scans model space, rescans the objects of the last scan, waits for boxes that hold numbers (and for a tolerance that is not too large to keep), finds nothing with no types, and scans the current drawing when the last scan is of another tab; Cancel changes nothing; the proposed tolerance goes in the box, a typed tolerance changes only its own type, and a removed type is added back; Import reads AutoCAD's file and Export writes its angle rows back; a file that cannot be read changes nothing.cargo test --workspace --locked --no-fail-fast: 8205 passed, 0 failed, 48 ignored (29 new).Not covered
.gcsfield that OCS does not know is not kept on Import and Export, and a file that starts with a byte order mark is not read. The file from AutoCAD 2027 has neither.Impact to Contributors
end_errorstakesTolerancesin place of onef64. A newModalKind::GeometryCleanupSettingsand a newAppConfigfield.🤖 Generated with Claude Code