Compare commits
No commits in common. "1f8457c136d48f73cfd09b75219080e9e4671984" and "6a639f2c7f69942fd40d3beb98f1ccc781d7259a" have entirely different histories.
1f8457c136
...
6a639f2c7f
4 changed files with 52 additions and 69 deletions
|
|
@ -22,7 +22,6 @@ class APIObject(BaseObject):
|
|||
feature.addProperty('App::PropertyBool', 'Connected', 'KiConnect', 'Is socket connected')
|
||||
feature.addProperty('App::PropertyInteger', 'DocumentCount', 'KiConnect', 'Count of open Documnets')
|
||||
|
||||
# XXX onDocumentRestored should not be called on creation
|
||||
self.onDocumentRestored(feature)
|
||||
|
||||
self.ping_connection()
|
||||
|
|
@ -45,6 +44,7 @@ class APIObject(BaseObject):
|
|||
setattr(self, 'boards', {})
|
||||
|
||||
self.kicad = KiCad()
|
||||
self.refresh_polygons()
|
||||
|
||||
parent = feature.getParent()
|
||||
if not parent: return
|
||||
|
|
|
|||
|
|
@ -4,7 +4,6 @@ import FreeCAD as App
|
|||
from . import settings
|
||||
import Part
|
||||
|
||||
from kipy import board_types as BoardTypes
|
||||
from kipy.board_types import Footprint3DModel, BoardArc, BoardPolygon, BoardSegment, PadStackShape
|
||||
from kipy.geometry import PolygonWithHoles, PolyLine, PolyLineNode, Vector2
|
||||
from kipy.proto.common.types import KiCadObjectType
|
||||
|
|
@ -198,8 +197,7 @@ def makeBoard(parent, kicad_board, polygon):
|
|||
def extract_polygons(board):
|
||||
# find polygons of Edge Cuts
|
||||
edge_cuts = [ edge for edge in board.get_shapes() if edge.layer == BoardLayer.BL_Edge_Cuts ]
|
||||
|
||||
polygons = [ edge for edge in edge_cuts if (isinstance(edge, BoardPolygon) or isinstance(edge, BoardArc) or isinstance(edge, BoardTypes.BoardCircle)) ]
|
||||
polygons = [ edge for edge in edge_cuts if (isinstance(edge, BoardPolygon) or isinstance(edge, BoardArc)) ]
|
||||
|
||||
return polygons
|
||||
|
||||
|
|
|
|||
|
|
@ -5,7 +5,6 @@ from . import settings
|
|||
import Part
|
||||
import Sketcher
|
||||
|
||||
from kipy import board_types as BoardTypes
|
||||
from kipy.board_types import Footprint3DModel, BoardPolygon, BoardSegment, PadStackShape
|
||||
from kipy.geometry import PolygonWithHoles, PolyLine, PolyLineNode, Vector2
|
||||
from kipy.proto.common.types import KiCadObjectType
|
||||
|
|
@ -58,92 +57,78 @@ class BoardSketchObject(BaseObject):
|
|||
if not board_polygon:
|
||||
raise BoardPolyNotFoundException('Board Polygon not found: ' + self.polygon_id)
|
||||
|
||||
# XXX: arc_count is a hack to address
|
||||
# https://codeberg.org/kiconnect/KiConnect/issues/2
|
||||
# below every other arc is skipped.
|
||||
arc_count = 0
|
||||
start = None
|
||||
|
||||
outline = board_polygon.polygons[0].outline
|
||||
line = []
|
||||
|
||||
if isinstance(board_polygon, BoardTypes.BoardCircle):
|
||||
print(board_polygon)
|
||||
else:
|
||||
outline = board_polygon.polygons[0].outline
|
||||
for node in outline:
|
||||
if node.has_arc:
|
||||
arc_count = arc_count + 1
|
||||
for node in outline:
|
||||
if node.has_arc:
|
||||
arc_count = arc_count + 1
|
||||
|
||||
if arc_count % 2 == 0:
|
||||
continue
|
||||
if arc_count % 2 == 0:
|
||||
continue
|
||||
|
||||
arc = node.arc
|
||||
arc = node.arc
|
||||
|
||||
arc_start = self.point_to_vector(arc.start)
|
||||
arc_mid = self.point_to_vector(arc.mid)
|
||||
arc_end = self.point_to_vector(arc.end)
|
||||
|
||||
if not start:
|
||||
start = arc_start
|
||||
arc_start = self.point_to_vector(arc.start)
|
||||
arc_mid = self.point_to_vector(arc.mid)
|
||||
arc_end = self.point_to_vector(arc.end)
|
||||
|
||||
# if there is already part of a LineSegment, connect it to the start of this Arc
|
||||
if len(line) == 1:
|
||||
idx = feature.addGeometry(Part.LineSegment(line[0], arc_start))
|
||||
feature.addConstraint(Sketcher.Constraint("Coincident", idx - 1, 2, idx, 1))
|
||||
if not start:
|
||||
start = arc_start
|
||||
|
||||
if line[0].x == arc_start.x:
|
||||
feature.addConstraint(Sketcher.Constraint("Vertical", idx))
|
||||
# if there is already part of a LineSegment, connect it to the start of this Arc
|
||||
if len(line) == 1:
|
||||
idx = feature.addGeometry(Part.LineSegment(line[0], arc_start))
|
||||
feature.addConstraint(Sketcher.Constraint("Coincident", idx - 1, 2, idx, 1))
|
||||
|
||||
if line[0].y == arc_start.y:
|
||||
feature.addConstraint(Sketcher.Constraint("Horizontal", idx))
|
||||
|
||||
line = []
|
||||
|
||||
idx = feature.addGeometry(Part.Arc(arc_start, arc_mid, arc_end))
|
||||
if idx > 1:
|
||||
feature.addConstraint(Sketcher.Constraint("Coincident", idx - 1, 2, idx, 1))
|
||||
|
||||
line.append(arc_end)
|
||||
elif node.has_point:
|
||||
vector = self.point_to_vector(node.point)
|
||||
|
||||
if not start:
|
||||
start = vector
|
||||
|
||||
line.append(vector)
|
||||
else:
|
||||
raise Exception('Hit unknown geometry type in board polygon')
|
||||
|
||||
if len(line) > 2: raise Exception('Too many points in line segment', line)
|
||||
|
||||
if len(line) == 2:
|
||||
idx = feature.addGeometry(Part.LineSegment(line[0], line[1]))
|
||||
if idx > 0:
|
||||
feature.addConstraint(Sketcher.Constraint("Coincident", idx - 1, 2, idx, 1))
|
||||
|
||||
if line[0].x == line[1].x:
|
||||
if line[0].x == arc_start.x:
|
||||
feature.addConstraint(Sketcher.Constraint("Vertical", idx))
|
||||
|
||||
if line[0].y == line[1].y:
|
||||
if line[0].y == arc_start.y:
|
||||
feature.addConstraint(Sketcher.Constraint("Horizontal", idx))
|
||||
|
||||
line = [line[1]]
|
||||
line = []
|
||||
|
||||
idx = feature.addGeometry(Part.Arc(arc_start, arc_mid, arc_end))
|
||||
if idx > 1:
|
||||
feature.addConstraint(Sketcher.Constraint("Coincident", idx - 1, 2, idx, 1))
|
||||
|
||||
if len(line) == 1:
|
||||
# XXX what if the final piece of geo is an arc?
|
||||
idx = feature.addGeometry(Part.LineSegment(start, line[0]))
|
||||
line.append(arc_end)
|
||||
elif node.has_point:
|
||||
vector = self.point_to_vector(node.point)
|
||||
|
||||
feature.addConstraint(Sketcher.Constraint("Coincident", 0, 1, idx, 1))
|
||||
feature.addConstraint(Sketcher.Constraint("Coincident", idx - 1, 2, idx, 2))
|
||||
if not start:
|
||||
start = vector
|
||||
|
||||
if line[0].x == start.x:
|
||||
line.append(vector)
|
||||
else:
|
||||
raise Exception('Hit unknown geometry type in board polygon')
|
||||
|
||||
if len(line) > 2: raise Exception('Too many points in line segment', line)
|
||||
|
||||
if len(line) == 2:
|
||||
idx = feature.addGeometry(Part.LineSegment(line[0], line[1]))
|
||||
feature.addConstraint(Sketcher.Constraint("Coincident", idx - 1, 2, idx, 1))
|
||||
|
||||
if line[0].x == line[1].x:
|
||||
feature.addConstraint(Sketcher.Constraint("Vertical", idx))
|
||||
|
||||
if line[0].y == start.y:
|
||||
if line[0].y == line[1].y:
|
||||
feature.addConstraint(Sketcher.Constraint("Horizontal", idx))
|
||||
else:
|
||||
FreeCAD.Console.PrintError("Bad line segment:", line)
|
||||
|
||||
line = [ line[1] ]
|
||||
|
||||
|
||||
if len(line) == 1:
|
||||
idx = feature.addGeometry(Part.LineSegment(start, line[0]))
|
||||
feature.addConstraint(Sketcher.Constraint("Coincident", 0, 1, idx, 1))
|
||||
feature.addConstraint(Sketcher.Constraint("Coincident", idx - 1, 2, idx, 2))
|
||||
else:
|
||||
FreeCAD.Console.PrintError("Bad line segment:", line)
|
||||
|
||||
feature.recompute()
|
||||
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ class Reload:
|
|||
except:
|
||||
print('failed to remove KiConnect')
|
||||
|
||||
for mod in [mod for mod in sys.modules if 'kicon' in mod or 'kipy' in mod]:
|
||||
for mod in [mod for mod in sys.modules if 'kicon' in mod]:
|
||||
print(f'Reloading {mod}')
|
||||
|
||||
importlib.reload(sys.modules[mod])
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue