I am building a sketch from vertices extracted from kicad. The problem is some of the vertices differ by a very small value.
For example one vertex is 37.2834 and the other is 37.28. I want these points to be coincident.
Is there some way to automatically make points coincident (after the sketch is build) if points differ by a small delta.
Here is the code that build my sketch:
Code: Select all
doc = freecad.app.newDocument()
sketch = doc.addObject("Sketcher::SketchObject", "EdgeCuts")
for x in edges:
if x.GetShape() == 0: # 0 is line segment
temp_x0=x.GetStart0()
temp_x1=x.GetEnd0()
sketch.addGeometry(Part.LineSegment(App.Vector(temp_x0.x/SCALE, temp_x0.y/SCALE, 0.0),
App.Vector(temp_x1.x/SCALE, temp_x1.y/SCALE, 0.0)), False)
if x.GetShape() == 2: #Arc
x0=x.GetStart()
m=x.GetArcMid()
x1=x.GetEnd()
arc = Part.Arc(App.Vector(x0.x/SCALE, x0.y/SCALE, 0.0), App.Vector(m.x/SCALE, m.y/SCALE, 0.0), App.Vector(x1.x/SCALE, x1.y/SCALE, 0.0))
sketch.addGeometry(arc,False)
I could keep a vertex list, and compare the euclidean distance when adding a new point.
Code: Select all
if (distance > delta) add to new vertex to list.
Thanks.