2323from unicorn .context import GCodeContext
2424from unicorn .svg_parser import SvgParser
2525
26+ #self.arg_parser.add_argument
27+
2628class MyEffect (inkex .Effect ):
2729 def __init__ (self ):
2830 inkex .Effect .__init__ (self )
29- self .OptionParser .add_option ("--pen-up-angle" ,
30- action = "store" , type = "float" ,
31+ self .arg_parser .add_argument ("--pen-up-angle" , type = float ,
3132 dest = "pen_up_angle" , default = "50.0" ,
3233 help = "Pen Up Angle" )
33- self .OptionParser .add_option ("--pen-down-angle" ,
34- action = "store" , type = "float" ,
34+ self .arg_parser .add_argument ("--pen-down-angle" , type = float ,
3535 dest = "pen_down_angle" , default = "30.0" ,
3636 help = "Pen Down Angle" )
37- self .OptionParser .add_option ("--start-delay" ,
38- action = "store" , type = "float" ,
37+ self .arg_parser .add_argument ("--start-delay" , type = float ,
3938 dest = "start_delay" , default = "150.0" ,
4039 help = "Delay after pen down command before movement in milliseconds" )
41- self .OptionParser .add_option ("--stop-delay" ,
42- action = "store" , type = "float" ,
40+ self .arg_parser .add_argument ("--stop-delay" , type = float ,
4341 dest = "stop_delay" , default = "150.0" ,
4442 help = "Delay after pen up command before movement in milliseconds" )
45- self .OptionParser .add_option ("--xy-feedrate" ,
46- action = "store" , type = "float" ,
43+ self .arg_parser .add_argument ("--xy-feedrate" , type = float ,
4744 dest = "xy_feedrate" , default = "3500.0" ,
4845 help = "XY axes feedrate in mm/min" )
49- self .OptionParser .add_option ("--z-feedrate" ,
50- action = "store" , type = "float" ,
46+ self .arg_parser .add_argument ("--z-feedrate" , type = float ,
5147 dest = "z_feedrate" , default = "150.0" ,
5248 help = "Z axis feedrate in mm/min" )
53- self .OptionParser .add_option ("--z-height" ,
54- action = "store" , type = "float" ,
49+ self .arg_parser .add_argument ("--z-height" , type = float ,
5550 dest = "z_height" , default = "0.0" ,
5651 help = "Z axis print height in mm" )
57- self .OptionParser .add_option ("--finished-height" ,
58- action = "store" , type = "float" ,
52+ self .arg_parser .add_argument ("--finished-height" , type = float ,
5953 dest = "finished_height" , default = "0.0" ,
6054 help = "Z axis height after printing in mm" )
61- self .OptionParser .add_option ("--register-pen" ,
62- action = "store" , type = "string" ,
55+ self .arg_parser .add_argument ("--register-pen" , type = str ,
6356 dest = "register_pen" , default = "true" ,
6457 help = "Add pen registration check(s)" )
65- self .OptionParser .add_option ("--x-home" ,
66- action = "store" , type = "float" ,
58+ self .arg_parser .add_argument ("--x-home" , type = float ,
6759 dest = "x_home" , default = "0.0" ,
6860 help = "Starting X position" )
69- self .OptionParser .add_option ("--y-home" ,
70- action = "store" , type = "float" ,
61+ self .arg_parser .add_argument ("--y-home" , type = float ,
7162 dest = "y_home" , default = "0.0" ,
7263 help = "Starting Y position" )
73- self .OptionParser .add_option ("--num-copies" ,
74- action = "store" , type = "int" ,
64+ self .arg_parser .add_argument ("--num-copies" , type = int ,
7565 dest = "num_copies" , default = "1" )
76- self .OptionParser .add_option ("--continuous" ,
77- action = "store" , type = "string" ,
66+ self .arg_parser .add_argument ("--continuous" , type = str ,
7867 dest = "continuous" , default = "false" ,
7968 help = "Plot continuously until stopped." )
80- self .OptionParser .add_option ("--pause-on-layer-change" ,
81- action = "store" , type = "string" ,
69+ self .arg_parser .add_argument ("--pause-on-layer-change" , type = str ,
8270 dest = "pause_on_layer_change" , default = "false" ,
8371 help = "Pause on layer changes." )
84- self .OptionParser .add_option ("--tab" ,
85- action = "store" , type = "string" ,
86- dest = "tab" )
87-
88- def output (self ):
89- self .context .generate ()
72+ self .arg_parser .add_argument ("--tab" , type = str , dest = "tab" )
9073
9174 def effect (self ):
9275 self .context = GCodeContext (self .options .xy_feedrate , self .options .z_feedrate ,
@@ -97,12 +80,20 @@ def effect(self):
9780 self .options .register_pen ,
9881 self .options .num_copies ,
9982 self .options .continuous ,
100- self .svg_file )
83+ self .options . input_file )
10184 parser = SvgParser (self .document .getroot (), self .options .pause_on_layer_change )
10285 parser .parse ()
10386 for entity in parser .entities :
10487 entity .get_gcode (self .context )
88+
89+ self .context .generate ()
90+ MyEffect .save_raw (self , self .context .generate ())
91+
92+ #self.save_raw(self, self.context.generate())
93+
94+ # def output(self):
95+ # self.context.generate()
96+
10597
10698if __name__ == '__main__' : #pragma: no cover
107- e = MyEffect ()
108- e .affect ()
99+ MyEffect ().run ()
0 commit comments