Compare commits
3 commits
984cb42b1c
...
796206f116
Author | SHA1 | Date | |
---|---|---|---|
|
796206f116 | ||
|
03fc42579f | ||
|
db3a25dbd2 |
2 changed files with 25 additions and 18 deletions
|
@ -41,7 +41,7 @@ class BoardObject(BaseObject):
|
|||
def onDocumentRestored(self, feature):
|
||||
super(BoardObject, self).onDocumentRestored(feature)
|
||||
|
||||
self.board_sketch = self.feature.get('BoardSketch')
|
||||
self.board_sketch = self.feature.getObject('BoardSketch')
|
||||
self.kicad_board = self.get_api().kicad.get_board()
|
||||
|
||||
@property
|
||||
|
@ -72,7 +72,7 @@ class BoardObject(BaseObject):
|
|||
|
||||
return self.board_sketch
|
||||
|
||||
def get_boardpoly(self):
|
||||
def get_boardpoly(self, polygon_id=None):
|
||||
# TODO remove in favor of extract_polygons class method
|
||||
board = self.kicad_board
|
||||
|
||||
|
@ -80,8 +80,10 @@ class BoardObject(BaseObject):
|
|||
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) ]
|
||||
|
||||
# XXX only single board supported at the moment
|
||||
return polygons[0]
|
||||
if polygon_id:
|
||||
return [ p for p in polygons if p.id.value == polygon_id ][0]
|
||||
else:
|
||||
return polygons
|
||||
|
||||
def pocket_vias(self):
|
||||
board = self.kicad_board
|
||||
|
|
|
@ -15,18 +15,35 @@ class BoardSketchObject(BaseObject):
|
|||
TYPE = 'KiConnect::BoardSketch'
|
||||
|
||||
def __init__(self, feature, kicad_board, board_polygon):
|
||||
self.board_polygon = board_polygon
|
||||
super(BoardSketchObject, self).__init__(feature)
|
||||
|
||||
#feature.Visibility = False
|
||||
|
||||
def execute(self, feature):
|
||||
feature.recompute()
|
||||
|
||||
def point_to_vector(self, point, offset=True):
|
||||
return (
|
||||
App.Vector(point.x,
|
||||
-point.y
|
||||
)) / 1000000.0 - (self.feature.BoardOffset.Base if offset else 0)
|
||||
|
||||
def setup_properties(self, feature):
|
||||
super(BoardSketchObject, self).setup_properties(feature)
|
||||
|
||||
feature.addProperty('App::PropertyPlacement', 'BoardOffset', 'KiConnect', 'Internal offset for zeroing out Footprint offset', hidden=True, read_only=True)
|
||||
feature.addProperty('App::PropertyVectorList', 'Vectors', 'KiConnect', 'Internal offset for zeroing out Footprint offset', hidden=True)
|
||||
|
||||
def sync_from(self):
|
||||
feature = self.feature
|
||||
vectors = []
|
||||
|
||||
for node in board_polygon.polygons[0].outline:
|
||||
for node in self.board_polygon.polygons[0].outline:
|
||||
vectors.append(self.point_to_vector(node.point))
|
||||
|
||||
self.feature.Vectors = vectors
|
||||
|
||||
def execute(self, feature):
|
||||
begin = None
|
||||
start = None
|
||||
|
||||
|
@ -48,18 +65,6 @@ class BoardSketchObject(BaseObject):
|
|||
|
||||
feature.recompute()
|
||||
|
||||
def point_to_vector(self, point, offset=True):
|
||||
return (
|
||||
App.Vector(point.x,
|
||||
-point.y
|
||||
)) / 1000000.0 - (self.feature.BoardOffset.Base if offset else 0)
|
||||
|
||||
def setup_properties(self, feature):
|
||||
super(BoardSketchObject, self).setup_properties(feature)
|
||||
|
||||
feature.addProperty('App::PropertyPlacement', 'BoardOffset', 'KiConnect', 'Internal offset for zeroing out Footprint offset', hidden=True, read_only=True)
|
||||
feature.addProperty('App::PropertyVectorList', 'Vectors', 'KiConnect', 'Internal offset for zeroing out Footprint offset', hidden=True)
|
||||
|
||||
def __getstate__(self):
|
||||
return None
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue