Compare commits
No commits in common. "796206f116e41ad00aff063477d77da0bbb1b87d" and "984cb42b1c6a4397d49f25dd431dbb2c5c23900a" have entirely different histories.
796206f116
...
984cb42b1c
2 changed files with 18 additions and 25 deletions
|
@ -41,7 +41,7 @@ class BoardObject(BaseObject):
|
||||||
def onDocumentRestored(self, feature):
|
def onDocumentRestored(self, feature):
|
||||||
super(BoardObject, self).onDocumentRestored(feature)
|
super(BoardObject, self).onDocumentRestored(feature)
|
||||||
|
|
||||||
self.board_sketch = self.feature.getObject('BoardSketch')
|
self.board_sketch = self.feature.get('BoardSketch')
|
||||||
self.kicad_board = self.get_api().kicad.get_board()
|
self.kicad_board = self.get_api().kicad.get_board()
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
@ -72,7 +72,7 @@ class BoardObject(BaseObject):
|
||||||
|
|
||||||
return self.board_sketch
|
return self.board_sketch
|
||||||
|
|
||||||
def get_boardpoly(self, polygon_id=None):
|
def get_boardpoly(self):
|
||||||
# TODO remove in favor of extract_polygons class method
|
# TODO remove in favor of extract_polygons class method
|
||||||
board = self.kicad_board
|
board = self.kicad_board
|
||||||
|
|
||||||
|
@ -80,10 +80,8 @@ class BoardObject(BaseObject):
|
||||||
edge_cuts = [ edge for edge in board.get_shapes() if edge.layer == BoardLayer.BL_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) ]
|
polygons = [ edge for edge in edge_cuts if isinstance(edge, BoardPolygon) ]
|
||||||
|
|
||||||
if polygon_id:
|
# XXX only single board supported at the moment
|
||||||
return [ p for p in polygons if p.id.value == polygon_id ][0]
|
return polygons[0]
|
||||||
else:
|
|
||||||
return polygons
|
|
||||||
|
|
||||||
def pocket_vias(self):
|
def pocket_vias(self):
|
||||||
board = self.kicad_board
|
board = self.kicad_board
|
||||||
|
|
|
@ -15,35 +15,18 @@ class BoardSketchObject(BaseObject):
|
||||||
TYPE = 'KiConnect::BoardSketch'
|
TYPE = 'KiConnect::BoardSketch'
|
||||||
|
|
||||||
def __init__(self, feature, kicad_board, board_polygon):
|
def __init__(self, feature, kicad_board, board_polygon):
|
||||||
self.board_polygon = board_polygon
|
|
||||||
super(BoardSketchObject, self).__init__(feature)
|
super(BoardSketchObject, self).__init__(feature)
|
||||||
|
|
||||||
#feature.Visibility = False
|
#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 = []
|
vectors = []
|
||||||
|
|
||||||
for node in self.board_polygon.polygons[0].outline:
|
for node in board_polygon.polygons[0].outline:
|
||||||
vectors.append(self.point_to_vector(node.point))
|
vectors.append(self.point_to_vector(node.point))
|
||||||
|
|
||||||
self.feature.Vectors = vectors
|
self.feature.Vectors = vectors
|
||||||
|
|
||||||
|
def execute(self, feature):
|
||||||
begin = None
|
begin = None
|
||||||
start = None
|
start = None
|
||||||
|
|
||||||
|
@ -65,6 +48,18 @@ class BoardSketchObject(BaseObject):
|
||||||
|
|
||||||
feature.recompute()
|
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):
|
def __getstate__(self):
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue