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):
|
||||
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()
|
||||
|
||||
@property
|
||||
|
@ -72,7 +72,7 @@ class BoardObject(BaseObject):
|
|||
|
||||
return self.board_sketch
|
||||
|
||||
def get_boardpoly(self, polygon_id=None):
|
||||
def get_boardpoly(self):
|
||||
# TODO remove in favor of extract_polygons class method
|
||||
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 ]
|
||||
polygons = [ edge for edge in edge_cuts if isinstance(edge, BoardPolygon) ]
|
||||
|
||||
if polygon_id:
|
||||
return [ p for p in polygons if p.id.value == polygon_id ][0]
|
||||
else:
|
||||
return polygons
|
||||
# XXX only single board supported at the moment
|
||||
return polygons[0]
|
||||
|
||||
def pocket_vias(self):
|
||||
board = self.kicad_board
|
||||
|
|
|
@ -15,35 +15,18 @@ 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 self.board_polygon.polygons[0].outline:
|
||||
for node in 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
|
||||
|
||||
|
@ -65,6 +48,18 @@ 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