Sketch clean not working in some cases
- Dominant language
- Python
- Stars
- 5.8k
- Forks
- 541
- Avg merge
- 3d 2h
- Merged PRs (30d)
- 5
Description
I fall on strange issue with clean on sketch, some faces of complexe sketch are not correctly removed. I tried to create a simple test case
From svg containing two path, I recreate edges, then face and making union from these two faces. The second face is completly inside the first one.
But following the path rotation of the second one (which is 2 arcs for a full circle) the clean function doesn't work
eddddd_ok.svg file:
```
```
eddddd_ko.svg file:
```
```
test.py file:
```
import numpy as np
import svgpathtools
import cadquery as cq
from typing import Union
from cadquery import Edge, Wire
def euclid_to_tuple(p, dim3=False):
if dim3:
return np.real(p), np.imag(p), 0
else:
return np.real(p), np.imag(p)
def to_wire(path, support: Union[cq.Workplane, cq.Sketch] = cq.Workplane("front"), mode="a"):
def convert(seg):
if isinstance(seg, svgpathtools.Line):
return Edge.makeLine(euclid_to_tuple(seg.start), euclid_to_tuple(seg.end))
elif isinstance(seg, svgpathtools.Arc):
points = euclid_to_tuple(seg.start), euclid_to_tuple(seg.point(0.5)), euclid_to_tuple(seg.end)
return Edge.makeThreePointArc(*points)
else:
raise Exception("Not supported: {0}".format(type(seg)))
edges = [convert(seg) for seg in path]
wires = Wire.combine(edges)
assert len(wires) == 1
wire = wires[0]
ret = support.face(wire, mode=mode)
return ret
for file in ['eddddd_ok.svg', 'eddddd_ko.svg']:
paths, attributes = svgpathtools.svg2paths(file)
sketch = cq.Sketch()
for path in paths:
sketch = to_wire(path, sketch, "a")
sketch = sketch.clean()
r = cq.Workplane("front").placeSketch(sketch).extrude(1, combine=False)
cq.exporters.export(r, file.replace("svg", "step"))
```
And here the results: https://imgur.com/a/4JZ0p26
The only difference here is:
Wire.combine([
Edge.makeThreePointArc((5.3882, 37.5328), (5.7382, 37.1828), (6.0882, 37.5328))
Edge.makeThreePointArc((6.0882, 37.5328), (5.7382, 37.8828), (5.3882, 37.5328))])
vs
Wire.combine([
Edge.makeThreePointArc((5.3882, 37.5328), (5.7382, 37.8828), (6.0882, 37.5328))
Edge.makeThreePointArc((6.0882, 37.5328), (5.7382, 37.1828), (5.3882, 37.5328))])
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.