Skip to content

Commit 6be37c9

Browse files
committed
fix sending
1 parent 6581c4a commit 6be37c9

File tree

2 files changed

+15
-3
lines changed

2 files changed

+15
-3
lines changed

gcodeplot.inx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
<param name="pen-up-speed" type="float" min="-1000000" max="1000000" precision="1" _gui-text="Movement speed (mm/s):" _gui-description="Speed moving with pen up (Default: 40)">40</param>
2323
<param name="pen-down-speed" type="float" min="-1000000" max="1000000" precision="1" _gui-text="Draw speed (mm/s):" _gui-description="Speed moving with pen down (Default: 35)">35</param>
2424
<param name="z-speed" type="float" min="-1000000" max="1000000" precision="1" _gui-text="Z-speed (mm/s):" _gui-description="Speed moving pen up/down (Default: 5)">5</param>
25-
<param name="send" type="string" _gui-text="Serial port to send gcode to (blank not to send)" _gui-description="If you enter the name of your serial port here (e.g., COM4), then you can directly send the file to your device."></param>
25+
<param name="send-and-save" type="string" _gui-text="Serial port to send gcode to (blank not to send)" _gui-description="If you enter the name of your serial port here (e.g., COM4), then you can directly send the file to your device."></param>
2626
<param name="send-speed" type="enum" _gui-text="Serial baud rate:" _gui-description="Baud rate of your serial device (Default: 115200)">
2727
<item value="115200">115200</item>
2828
<item value="300">300</item>

gcodeplot.py

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -664,6 +664,7 @@ def help(error=False):
664664
toolMode = "custom"
665665
booleanExtractColor = False
666666
quiet = False
667+
sendAndSave = False
667668

668669
try:
669670
opts, args = getopt.getopt(sys.argv[1:], "UR:Uhdulw:P:o:Oc:LT:M:m:A:XHrf:na:D:t:s:S:x:y:z:Z:p:f:F:",
@@ -674,7 +675,7 @@ def help(error=False):
674675
'shading-angle=', 'shading-crosshatch', 'no-shading-crosshatch', 'shading-avoid-outline',
675676
'pause-at-start', 'no-pause-at-start', 'min-x=', 'max-x=', 'min-y=', 'max-y=',
676677
'no-shading-avoid-outline', 'shading-darkest=', 'shading-lightest=', 'stroke-all', 'no-stroke-all', 'gcode-pause', 'dump-options', 'tab=', 'extract-color=', 'sort', 'no-sort', 'simulation', 'no-simulation', 'tool-offset=', 'overcut=',
677-
'boolean-shading-crosshatch=', 'boolean-sort=', 'tool-mode=' ], )
678+
'boolean-shading-crosshatch=', 'boolean-sort=', 'tool-mode=', 'send-and-save=' ], )
678679

679680
if len(args) + len(opts) == 0:
680681
raise getopt.GetoptError("invalid commandline")
@@ -732,6 +733,10 @@ def help(error=False):
732733
tolerance = float(arg)
733734
elif opt in ('-s', '--send'):
734735
sendPort = None if len(arg.strip()) == 0 else arg
736+
elif opt == '--send-and-save':
737+
sendPort = None if len(arg.strip()) == 0 else arg
738+
if sendPort is not None:
739+
sendAndSave = True
735740
elif opt == '--no-send':
736741
sendPort = None
737742
elif opt in ('-S', '--send-speed'):
@@ -985,17 +990,24 @@ def help(error=False):
985990
plotter=plotter, gcodePause=gcodePause, pens=pens, pauseAtStart=pauseAtStart, simulation=svgSimulation)
986991

987992
if g:
993+
dump = True
994+
988995
if sendPort is not None and not svgSimulation:
989996
import gcodeplotutils.sendgcode as sendgcode
997+
998+
dump = sendAndSave
999+
9901000
if hpglOut:
9911001
sendgcode.sendHPGL(port=sendPort, speed=sendSpeed, commands=g)
9921002
else:
9931003
sendgcode.sendGcode(port=sendPort, speed=sendSpeed, commands=g, gcodePause=gcodePause, plotter=plotter, variables=variables, formulas=formulas)
994-
else:
1004+
1005+
if dump:
9951006
if hpglOut:
9961007
sys.stdout.write(g)
9971008
else:
9981009
print('\n'.join(g))
1010+
9991011
else:
10001012
sys.stderr.write("No points.")
10011013
sys.exit(1)

0 commit comments

Comments
 (0)