本文整理汇总了Python中shape.Shape.getType方法的典型用法代码示例。如果您正苦于以下问题:Python Shape.getType方法的具体用法?Python Shape.getType怎么用?Python Shape.getType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类shape.Shape
的用法示例。
在下文中一共展示了Shape.getType方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _processPins
# 需要导入模块: from shape import Shape [as 别名]
# 或者: from shape.Shape import getType [as 别名]
def _processPins(self):
"""
Converts pins into 'shapes'
"""
pins = self._footprint.get('pins') or {}
for pin in pins:
pin_location = pins[pin]['layout']['location'] or [0, 0]
try:
pad_name = pins[pin]['layout']['pad']
except:
msg.error("Each defined 'pin' must have a 'pad' name that is defined in the 'pads' dection of the footprint.")
try:
pad_dict = self._footprint['pads'][pad_name]
except:
msg.error("There doesn't seem to be a pad definition for pad '%s'." % pad_name)
# Get the pin's rotation, if any
pin_rotate = pins[pin]['layout'].get('rotate') or 0
shapes = pad_dict.get('shapes') or []
for shape_dict in shapes:
shape_dict = shape_dict.copy()
# Which layer(s) to place the shape on
layers = utils.getExtendedLayerList(shape_dict.get('layers') or ['top'])
# Add the pin's location to the pad's location
shape_location = shape_dict.get('location') or [0, 0]
shape_dict['location'] = [shape_location[0] + pin_location[0],
shape_location[1] + pin_location[1]]
# Add the pin's rotation to the pad's rotation
shape_dict['rotate'] = (shape_dict.get('rotate') or 0) + pin_rotate
# Determine if and which label to show
show_name = pins[pin]['layout'].get('show-label') or True
if show_name == True:
pin_label = pins[pin]['layout'].get('label') or pin
for layer in layers:
shape = Shape(shape_dict)
style = Style(shape_dict, 'conductor')
shape.setStyle(style)
try:
self._shapes['conductor'][layer].append(shape)
except:
self._shapes['conductor'][layer] = []
self._shapes['conductor'][layer].append(shape)
for stype in ['soldermask','solderpaste']:
# Get a custom shape specification if it exists
sdict_list = shape_dict.get(stype)
# Not defined; default
if sdict_list == None:
# Use default settings for shape based on
# the pad shape
sdict = shape_dict.copy()
# Which shape type is the pad?
shape_type = shape.getType()
# Apply modifier based on shape type
if shape_type == 'path':
sdict['scale'] = shape.getScale()*config.brd['distances'][stype]['path-scale']
elif shape_type in ['rect', 'rectangle']:
sdict['width'] += config.brd['distances'][stype]['rect-buffer']
sdict['height'] += config.brd['distances'][stype]['rect-buffer']
elif shape_type in ['circ', 'circle']:
sdict['diameter'] += config.brd['distances'][stype]['circle-buffer']
else:
pass
# Create shape based on new dictionary
sshape = Shape(sdict)
# Define style
sstyle = Style(sdict, stype)
# Apply style
sshape.setStyle(sstyle)
# Add shape to footprint's shape dictionary
#self._shapes[stype][layer].append(sshape)
try:
self._shapes[stype][layer].append(sshape)
except:
self._shapes[stype][layer] = []
self._shapes[stype][layer].append(sshape)
#.........这里部分代码省略.........
示例2: _processPins
# 需要导入模块: from shape import Shape [as 别名]
# 或者: from shape.Shape import getType [as 别名]
def _processPins(self):
"""
Converts pins into 'shapes'
"""
try:
pins = self._footprint['pins']
except:
msg.error("Cannot find any 'pins' specified!")
for pin in pins:
pin_location = pins[pin]['layout']['location'] or [0, 0]
try:
pad_name = pins[pin]['layout']['pad']
except:
msg.error("Each defined 'pin' must have a 'pad' name that is defined in the 'pads' dection of the footprint.")
try:
pad_dict = self._footprint['pads'][pad_name]
except:
msg.error("There doesn't seem to be a pad definition for pad '%s'." % pad_name)
# Get the pin's rotation, if any
pin_rotate = pins[pin]['layout'].get('rotate') or 0
shapes = pad_dict.get('shapes') or []
for shape_dict in shapes:
shape_dict = shape_dict.copy()
# Which layer(s) to place the shape on
layers = shape_dict.get('layers') or ['top']
# Add the pin's location to the pad's location
shape_location = shape_dict.get('location') or [0, 0]
shape_dict['location'] = [shape_location[0] + pin_location[0],
shape_location[1] + pin_location[1]]
# Add the pin's rotation to the pad's rotation
shape_dict['rotate'] = (shape_dict.get('rotate') or 0) + pin_rotate
# Determine if and which label to show
show_name = pins[pin]['layout'].get('show-label') or True
if show_name == True:
pin_label = pins[pin]['layout'].get('label')
if pin_label == None:
pin_label = pin
pn_label = None
# The same shape can go on multiple layers
for layer in layers:
shape = Shape(shape_dict)
style = Style(shape_dict, 'copper')
shape.setStyle(style)
try:
# This will capture of 'layer' is defined as a
# list rather than a string. Ther's bound to
# be a better way of doing this
self._shapes['copper'][layer].append(shape)
except:
msg.error("The same pad shape can be placed on multiple layers. Even if it is only placed on a single layer, the layer needs to be defined as an array, for example, 'layer':['top']")
# Soldermask shape, if any is specified
sm_dict = shape_dict.get('soldermask')
if sm_dict == None:
sm_dict = shape_dict.copy()
sp_dict = shape_dict.copy()
shape_type = shape.getType()
if shape_type == 'path':
sm_dict['scale'] = shape.getScale()*config.brd['soldermask']['path-scale']
sp_dict['scale'] = shape.getScale()*config.brd['solderpaste']['path-scale']
elif shape_type in ['rect', 'rectangle']:
sm_dict['width'] += config.brd['soldermask']['rect-buffer']
sm_dict['height'] += config.brd['soldermask']['rect-buffer']
sp_dict['width'] += config.brd['solderpaste']['rect-buffer']
sp_dict['height'] += config.brd['solderpaste']['rect-buffer']
elif shape_type in ['circ', 'circle']:
sm_dict['diameter'] += config.brd['soldermask']['circle-buffer']
sp_dict['diameter'] += config.brd['solderpaste']['circle-buffer']
else:
pass
sm_shape = Shape(sm_dict)
sp_shape = Shape(sp_dict)
sm_style = Style(sm_dict, 'soldermask')
sp_style = Style(sp_dict, 'soldermask')
sm_shape.setStyle(sm_style)
sp_shape.setStyle(sp_style)
self._shapes['soldermask'][layer].append(sm_shape)
self._shapes['solderpaste'][layer].append(sp_shape)
elif sm_dict == {}:
# This indicates that we don't want any soldermask
#.........这里部分代码省略.........