本文整理汇总了Python中plugin.Plugin.apply_cutting_overlap方法的典型用法代码示例。如果您正苦于以下问题:Python Plugin.apply_cutting_overlap方法的具体用法?Python Plugin.apply_cutting_overlap怎么用?Python Plugin.apply_cutting_overlap使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类plugin.Plugin
的用法示例。
在下文中一共展示了Plugin.apply_cutting_overlap方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: run
# 需要导入模块: from plugin import Plugin [as 别名]
# 或者: from plugin.Plugin import apply_cutting_overlap [as 别名]
def run(self):
""" Converts an SVG into HPGL. """
# Set initial HPGL commands
hpgl = ['IN','SP1']
hpgl.extend(self.commands['send_before'])
if self.device['cutting_force'][1]:
hpgl.append('FS%d'%self.device['cutting_force'][0])
if self.device['cutting_speed'][1]:
hpgl.append('VS%d'%self.device['cutting_speed'][0])
# Read the input SVG into a Graphic to provide easy manipulation.
g = Graphic(self.input)
g.set_rotation(self.device['axis_rotation'])
g.set_mirror_x(True) # The coordinate systems are flipped in HPGL from SVG
g.set_scale(self.device['axis_scale'][0]*HPGL_SCALE,self.device['axis_scale'][1]*HPGL_SCALE)
g.set_position(self.device['axis_translate'][0],self.device['axis_translate'][1])
g.set_smoothness(1)
# Create the HPGL data
paths = g.get_polyline()
# Apply device specific settings
if self.device['cutting_overlap'][1]:
Plugin.apply_cutting_overlap(paths,self.device['cutting_overlap'][0])
if self.device['cutting_blade_offset'][1]:
Plugin.apply_cutting_blade_offset(paths,self.device['cutting_blade_offset'][0])
data = []
for path in paths:
x,y = path.pop(0)[1]
data.append('PU%i,%i'%(round(x),round(y)))
cmd = "PD"
for line in path:
x,y = line[1]
cmd +='%i,%i,'%(round(x),round(y))
data.append(cmd[:-1])
hpgl.extend(data)
hpgl.extend(self.commands['send_after'])
pos = self.plot['finish_position']
hpgl.append('PU%i,%i'%(round(self.device['axis_scale'][0]*HPGL_SCALE*pos[0]),round(y*self.device['axis_scale'][1]*HPGL_SCALE*pos[1])))
# Not friendly for large files!
self.output = ";\n".join(hpgl)+";"