more cleanup on Board > BoardSketch. sync_from after onDocumentLoaded now works
This commit is contained in:
		
							parent
							
								
									c85d038700
								
							
						
					
					
						commit
						93eb0d0483
					
				
					 2 changed files with 9 additions and 14 deletions
				
			
		|  | @ -16,6 +16,8 @@ from . import board_sketch as BoardSketch | |||
| class BoardObject(BaseObject): | ||||
|     TYPE = 'KiConnect::Board' | ||||
| 
 | ||||
|     save_keys = [ 'polygon_id' ] | ||||
| 
 | ||||
|     def __init__(self, feature, kicad_board, board_polygon): | ||||
|         self.feature = feature | ||||
|         self.substrate_body = None | ||||
|  |  | |||
|  | @ -14,8 +14,12 @@ from .bases import BaseObject, BaseViewProvider | |||
| class BoardSketchObject(BaseObject): | ||||
|     TYPE = 'KiConnect::BoardSketch' | ||||
| 
 | ||||
|     save_keys = [ 'polygon_id' ] | ||||
| 
 | ||||
|     def __init__(self, feature, kicad_board, board_polygon): | ||||
|         self.board_polygon = board_polygon | ||||
|         self.polygon_id = board_polygon.id.value | ||||
| 
 | ||||
|         super(BoardSketchObject, self).__init__(feature) | ||||
| 
 | ||||
|         #feature.Visibility = False | ||||
|  | @ -23,12 +27,6 @@ class BoardSketchObject(BaseObject): | |||
|     def execute(self, feature): | ||||
|         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): | ||||
|         return ( | ||||
|             App.Vector(point.x, | ||||
|  | @ -45,12 +43,10 @@ class BoardSketchObject(BaseObject): | |||
|         feature = self.feature | ||||
|         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: | ||||
|         board_polygon = self.get_api().get_polygon(self.polygon_id) | ||||
| 
 | ||||
|         for node in board_polygon.polygons[0].outline: | ||||
|             vectors.append(self.point_to_vector(node.point)) | ||||
| 
 | ||||
|         self.feature.Vectors = vectors | ||||
|  | @ -76,9 +72,6 @@ class BoardSketchObject(BaseObject): | |||
| 
 | ||||
|         feature.recompute() | ||||
| 
 | ||||
|     def __getstate__(self): | ||||
|         return None | ||||
| 
 | ||||
| class BoardSketchViewProvider(BaseViewProvider): | ||||
|     TYPE = 'KiConnect::BoardSketch' | ||||
|     #ICON = 'board.svg' | ||||
|  |  | |||
		Loading…
	
	Add table
		
		Reference in a new issue