chore: clean up #181
This commit is contained in:
+19
-17
@@ -113,24 +113,26 @@ class ProcessManager:
|
||||
netlist_writer = pcbnew.IPC356D_WRITER(self.board)
|
||||
netlist_writer.Write(os.path.join(temp_dir, netlistFileName))
|
||||
|
||||
def _get_footprint_position(self, footprint):
|
||||
attributes = footprint.GetAttributes()
|
||||
#determin origin type by packge type
|
||||
if attributes & pcbnew.FP_SMD:
|
||||
origin_type='Anchor'
|
||||
else:
|
||||
origin_type='Center'
|
||||
|
||||
#allow user override
|
||||
key='Origin'
|
||||
if footprint_has_field(footprint, key):
|
||||
origin_type_override = str(footprint_get_field(footprint, key)).capitalize()
|
||||
if origin_type_override in ['Anchor','Center']:
|
||||
origin_type=origin_type_override
|
||||
def _get_footprint_position(self, footprint):
|
||||
"""Calculate position based on center of pads / bounding box."""
|
||||
|
||||
if origin_type=='Anchor':
|
||||
attributes = footprint.GetAttributes()
|
||||
# determine origin type by package type
|
||||
if attributes & pcbnew.FP_SMD:
|
||||
origin_type = 'Anchor'
|
||||
else:
|
||||
origin_type = 'Center'
|
||||
|
||||
# allow user override
|
||||
key = 'Origin'
|
||||
if footprint_has_field(footprint, key):
|
||||
origin_type_override = str(footprint_get_field(footprint, key)).strip().capitalize()
|
||||
if origin_type_override in ['Anchor', 'Center']:
|
||||
origin_type = origin_type_override
|
||||
|
||||
if origin_type == 'Anchor':
|
||||
position = footprint.GetPosition()
|
||||
else: #if type_origin=='center' or anything ele
|
||||
else: # if type_origin == 'Center' or anything else
|
||||
pads = footprint.Pads()
|
||||
if len(pads) > 0:
|
||||
# get bounding box based on pads only to ignore non-copper layers, e.g. silkscreen
|
||||
@@ -139,7 +141,7 @@ class ProcessManager:
|
||||
bbox.Merge(pad.GetBoundingBox()) # expand bounding box
|
||||
position = bbox.GetCenter()
|
||||
else:
|
||||
position = footprint.GetPosition() #if we have no pads we fallback to anchor
|
||||
position = footprint.GetPosition() # if we have no pads we fallback to anchor
|
||||
|
||||
return position
|
||||
|
||||
|
||||
Reference in New Issue
Block a user