Compare commits
No commits in common. "205254a4f3ad1a598ec1830c0ce58fb2463b1e90" and "03fc42579f5b50d63bae698c94c8b0ee245e3949" have entirely different histories.
205254a4f3
...
03fc42579f
6 changed files with 16 additions and 27 deletions
|
@ -54,7 +54,7 @@ class BaseObject:
|
||||||
self.feature.addExtension(ext)
|
self.feature.addExtension(ext)
|
||||||
|
|
||||||
def setup_properties(self, feature):
|
def setup_properties(self, feature):
|
||||||
feature.addProperty('App::PropertyString', 'Type', 'KiConnect', 'Internal KiConnect Type', hidden=True)
|
feature.addProperty('App::PropertyString', 'Type', 'KiConnect', 'Internal KiConnect Type', read_only=True, hidden=True)
|
||||||
|
|
||||||
def sync_from(self):
|
def sync_from(self):
|
||||||
pass
|
pass
|
||||||
|
|
|
@ -19,7 +19,6 @@ class BoardObject(BaseObject):
|
||||||
def __init__(self, feature, kicad_board, board_polygon):
|
def __init__(self, feature, kicad_board, board_polygon):
|
||||||
self.feature = feature
|
self.feature = feature
|
||||||
self.kicad_board = kicad_board
|
self.kicad_board = kicad_board
|
||||||
self.board_sketch = None
|
|
||||||
# TODO add this to FreeCAD Preferences and Property?
|
# TODO add this to FreeCAD Preferences and Property?
|
||||||
self.do_offset = True
|
self.do_offset = True
|
||||||
# TODO needs to be resotred in onDocumentRestored
|
# TODO needs to be resotred in onDocumentRestored
|
||||||
|
@ -73,9 +72,6 @@ class BoardObject(BaseObject):
|
||||||
|
|
||||||
return self.board_sketch
|
return self.board_sketch
|
||||||
|
|
||||||
def get_polygon(self, kiid):
|
|
||||||
return [ s for s in self.kicad_board.get_shapes() if s.id.value == kiid ][0]
|
|
||||||
|
|
||||||
def get_boardpoly(self):
|
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
|
||||||
|
@ -132,8 +128,17 @@ class BoardObject(BaseObject):
|
||||||
Pulls outline from KiCAD PolygonBoard and saves points as Vectors
|
Pulls outline from KiCAD PolygonBoard and saves points as Vectors
|
||||||
'''
|
'''
|
||||||
|
|
||||||
if self.board_sketch:
|
# bit of a quick hack to keep the board in one place, needs more testing
|
||||||
self.board_sketch.Proxy.sync_from()
|
if self.do_offset and not self.feature.BoardOffset:
|
||||||
|
bb = self.board_polygon.bounding_box()
|
||||||
|
self.feature.BoardOffset.Base = (App.Vector(bb.pos.x, -bb.pos.y) + App.Vector(bb.size.x, -bb.size.y) / 2) / 1000000.0
|
||||||
|
|
||||||
|
vectors = []
|
||||||
|
|
||||||
|
for node in self.board_polygon.polygons[0].outline:
|
||||||
|
vectors.append(self.point_to_vector(node.point))
|
||||||
|
|
||||||
|
self.feature.Vectors = vectors
|
||||||
|
|
||||||
def sync_to(self):
|
def sync_to(self):
|
||||||
board = self.kicad_board
|
board = self.kicad_board
|
||||||
|
|
|
@ -23,12 +23,6 @@ class BoardSketchObject(BaseObject):
|
||||||
def execute(self, feature):
|
def execute(self, feature):
|
||||||
feature.recompute()
|
feature.recompute()
|
||||||
|
|
||||||
def get_parent_board(self):
|
|
||||||
try:
|
|
||||||
return self.feature.getParent().getParent().Proxy
|
|
||||||
except:
|
|
||||||
return None
|
|
||||||
|
|
||||||
def point_to_vector(self, point, offset=True):
|
def point_to_vector(self, point, offset=True):
|
||||||
return (
|
return (
|
||||||
App.Vector(point.x,
|
App.Vector(point.x,
|
||||||
|
@ -45,11 +39,6 @@ class BoardSketchObject(BaseObject):
|
||||||
feature = self.feature
|
feature = self.feature
|
||||||
vectors = []
|
vectors = []
|
||||||
|
|
||||||
board = self.get_parent_board()
|
|
||||||
if board:
|
|
||||||
self.board_polygon = board.get_polygon(board.polygon_id)
|
|
||||||
|
|
||||||
# board.get_shapes needs to be called to ensure polygons are actually up to date
|
|
||||||
for node in self.board_polygon.polygons[0].outline:
|
for node in self.board_polygon.polygons[0].outline:
|
||||||
vectors.append(self.point_to_vector(node.point))
|
vectors.append(self.point_to_vector(node.point))
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,7 @@
|
||||||
import FreeCAD as App
|
|
||||||
import FreeCADGui as Gui
|
import FreeCADGui as Gui
|
||||||
|
|
||||||
class Syncable:
|
class Syncable:
|
||||||
SYNCABLES = [ 'KiConnect::Project', 'KiConnect::Board', 'KiConnect::Parts', 'KiConnect::BoardBody', 'KiConnect::BoardSketch' ]
|
SYNCABLES = [ 'KiConnect::Project', 'KiConnect::Board', 'KiConnect::Parts', 'KiConnect::BoardBody', ]
|
||||||
|
|
||||||
def IsActive(self):
|
def IsActive(self):
|
||||||
sel = Gui.Selection.getSelection()
|
sel = Gui.Selection.getSelection()
|
||||||
|
@ -42,5 +41,3 @@ class Syncable:
|
||||||
getattr(feature, self.method)()
|
getattr(feature, self.method)()
|
||||||
|
|
||||||
s.recompute()
|
s.recompute()
|
||||||
|
|
||||||
App.ActiveDocument.recompute()
|
|
||||||
|
|
|
@ -15,13 +15,12 @@ from .bases import BaseObject, BaseViewProvider
|
||||||
class PartsObject(BaseObject):
|
class PartsObject(BaseObject):
|
||||||
TYPE = 'KiConnect::Parts'
|
TYPE = 'KiConnect::Parts'
|
||||||
|
|
||||||
def __init__(self, feature):
|
|
||||||
super(PartsObject, self).__init__(feature)
|
|
||||||
|
|
||||||
def execute(self, feature):
|
def execute(self, feature):
|
||||||
super(PartsObject, self).execute(feature)
|
super(PartsObject, self).execute(feature)
|
||||||
|
|
||||||
def sync_from(self):
|
self.import_footprints()
|
||||||
|
|
||||||
|
def import_footprints(self):
|
||||||
kiconn_board = self.feature.getParentGroup()
|
kiconn_board = self.feature.getParentGroup()
|
||||||
kicad_board = self.get_api().kicad.get_board()
|
kicad_board = self.get_api().kicad.get_board()
|
||||||
|
|
||||||
|
|
|
@ -32,7 +32,6 @@ class Project:
|
||||||
kicad_board = self.API.Proxy.kicad.get_board()
|
kicad_board = self.API.Proxy.kicad.get_board()
|
||||||
|
|
||||||
polygons = Board.extract_polygons(kicad_board)
|
polygons = Board.extract_polygons(kicad_board)
|
||||||
|
|
||||||
for polygon in polygons:
|
for polygon in polygons:
|
||||||
self.board = Board.makeBoard(self.feature, kicad_board, polygon)
|
self.board = Board.makeBoard(self.feature, kicad_board, polygon)
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue