FreeCAD / FreeCAD/FreeCAD

Sketcher: regular polygon can collapse into a degenerate shape when circle centers are constrained coincident to polygon vertices

Open
#31,355 3 comments 0 reactions 0 assignees View on GitHub
Mod: Sketcher Status: Needs confirmation Topic: GCS
Dominant language
C++
Stars
33.6k
Forks
6k
Avg merge
3d 15h
Merged PRs (30d)
196

Description

### Problem description

**Problem description**

While building a circular hole pattern in Sketcher, a regular construction polygon can occasionally collapse into a different degenerate shape when a circle center is constrained coincident to one of the polygon vertices.

Workflow:

1. Create a regular polygon in Sketcher and mark it as construction geometry.
2. Use the polygon vertices as a placement guide for a circular hole pattern.
3. Create a hole circle away from the polygon.
4. Select the hole circle center and a polygon vertex.
5. Apply a coincident constraint.
6. Repeat for additional holes.

Expected result:

- The selected circle center moves onto the selected polygon vertex.
- The regular polygon remains a 10-sided polygon.

Actual result:

- Sometimes the polygon suddenly collapses into a different solved state.
- In my case, the original 10-gon became a degenerate shape with repeated vertices / duplicated edges and looked like it had dropped to 8 points.
- `Ctrl+Z` restores the sketch.
- Retrying the exact same action sometimes works and sometimes reproduces the collapse again.

This is disruptive because the workflow appears normal until the sketch solver jumps to a different valid-but-unintended configuration.

I was able to capture a failure case with a macro and a crashed project file.

Recorded macro excerpt from the failure:

```python
App.getDocument('Unnamed').getObject('Sketch003').addConstraint(Sketcher.Constraint('Coincident',28,3,8,2))
```

That failing step was recorded after several successful circle-to-vertex coincidences in the same sketch.

Observed project state:

- Original polygon sketch geometry was 10 line segments plus a construction circle.
- After the failure, the polygon line segments were still present, but the solved geometry had collapsed to 8 unique vertex locations, with repeated/duplicated edges.
- The geometry was not deleted; it was solved into a degenerate alternate configuration.

This suggests the regular polygon construction may be underconstrained or ambiguously constrained in a way that allows alternate equal-chord solutions on the same construction circle, and the added coincident constraints can push the solver into one of those unintended solutions.

**Reproduction recipe**

1. Open the attached project file before the failure if available, or use the attached failed project to inspect the resulting state.
2. Edit `Body001.Sketch003` (`Roller Sketch`).
3. Create a detached circle.
4. Select the circle center and then a regular polygon vertex.
5. Apply `Coincident`.
6. Repeat until the polygon collapses.

In the captured failure sequence, the macro recorded these successful/failing coincidence additions:

```python
App.getDocument('Unnamed').getObject('Sketch003').addConstraint(Sketcher.Constraint('Coincident',24,3,3,2))
App.getDocument('Unnamed').getObject('Sketch003').addConstraint(Sketcher.Constraint('Coincident',25,3,4,2))
App.getDocument('Unnamed').getObject('Sketch003').addConstraint(Sketcher.Constraint('Coincident',0,1,26,3))
App.getDocument('Unnamed').getObject('Sketch003').addConstraint(Sketcher.Constraint('Coincident',5,2,27,3))
App.getDocument('Unnamed').getObject('Sketch003').addConstraint(Sketcher.Constraint('Coincident',28,3,8,2))
```

The last one is the step after which the polygon collapsed in the saved failure case.

**Full version info**

Please replace this section with the exact output from `Help > About FreeCAD > Copy to clipboard`.

Example context for this report:

```text
FreeCAD 1.1.1
Sketcher workbench
```

**Subproject(s) affected**

- Sketcher

**Anything else?**

Artifacts available for attachment:

- Macro:
`/home/me/.local/share/FreeCAD/v1-1/Macro/Add circle to polygon until crash.FCMacro`
- Failed project:
`/home/me/Documents/PPump -crashed.FCStd`

Local analysis of the failed file:

- The failed project contains `Sketch003` labeled `Roller Sketch`.
- The regular polygon constraints are still present after failure:
- closed chain coincidences
- equal-length constraints
- point-on-construction-circle constraints
- The polygon geometry was solved into a degenerate state rather than deleted.
- The failure did not look like a simple wrong-selection bug; the recorded low-level coincident constraint targeted the expected circle center and polygon vertex.

If useful, I can also provide a minimal analysis summary of the sketch state before/after failure.

### Workbench affected?

Sketcher

### Steps to reproduce

[Case files.tar.gz](https://github.com/user-attachments/files/30056172/Case.files.tar.gz)

### Expected behavior

The circle should be added to the polygon vertex selected.

### Actual behavior

The polygon changes from a 10 point polygon to an 8 point polygon.

Before:

Image

After:

Image

### Development version About Info (in Safe Mode)

```shell
OS: Fedora Linux 44 (Workstation Edition) (KDE/plasma/wayland)
Architecture: x86_64
Version: 1.1.1.Unknown
Build date: Unknown
Build type: Unknown
Python 3.14.5, Qt 6.11.1, Coin 4.0.7, Vtk 9.5.2, boost 1_90, Eigen3 5.0.1, PySide 6.11.1
shiboken 6.11.1, SMESH 7.7.1.0, xerces-c 3.3.0, OCC 7.9.1
Locale: English/United States (en_US)
Navigation Style/Orbit Style/Rotation Mode: CAD/Trackball/Drag at cursor
Stylesheet/Theme/QtStyle: unset/FreeCAD Classic/
Logical DPI/Physical DPI/Pixel Ratio: 96/91.9477/1
Installed mods:
* 3D_Printing_Tools
* QuickMeasure 2022.10.28
* A2plus 0.4.68
* CurvedShapes 1.0.14
* MakerWorkbench 1.0.1
* Curves 0.6.71
* Assembly4 0.61.0
* CfdOF 1.36.3
* freecad.optics_design_workbench 0.7.3
* Plot 2026.4.15

This build is also available here:
https://copr.fedorainfracloud.org/coprs/linuxguy123/freecad
```

### Last known good version (optional)

```shell

```

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the failure in FreeCAD Sketcher with Body001.Sketch003 (Roller Sketch), using the attached Case.files.tar.gz and the recorded macro constraints. Inspect the regular polygon's equal-length, closed-chain, and point-on-construction-circle constraints before and after the final Coincident operation. Done means repeated circle-center coincidences no longer move the polygon into a degenerate configuration.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp, python
Domain
design, desktop-dev
Issue type
Bug
Difficulty
5/5
Estimated time
Over a week
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.