@@ -2019,7 +2019,10 @@ def cp_to_list(self,i) :
2019
2019
2020
2020
def l (self , i ) :
2021
2021
return cspseglength ( self .cp_to_list (i ), self .cp_to_list (i + 1 ), tolerance = 0.001 )
2022
-
2022
+
2023
+ def l_at_t (self , i , t ) :
2024
+ return CSPsubpath (self .headi (i ,t )).l (0 )
2025
+
2023
2026
def t_at_l (self , i , l , self_l = None , tolerance = 0.001 ) :
2024
2027
if self_l == None : self_l = self .l (i )
2025
2028
if self_l == 0 : return 0.
@@ -2093,9 +2096,8 @@ def cut_head_l(self,l):
2093
2096
def cut_tail_l (self ,l ):
2094
2097
return self .headl (self .length ()- l )
2095
2098
2096
-
2097
- def split (self ,i ,t = .5 ) :
2098
- sp1 ,sp2 = self .cp_to_list (i ), self .cp_to_list (i + 1 )
2099
+ def split_seg (sp1 ,sp2 ) :
2100
+ # return P(sp1) P(sp2) P(sp3)
2099
2101
[x1 ,y1 ],[x2 ,y2 ],[x3 ,y3 ],[x4 ,y4 ] = sp1 [1 ], sp1 [2 ], sp2 [0 ], sp2 [1 ]
2100
2102
x12 = x1 + (x2 - x1 )* t
2101
2103
y12 = y1 + (y2 - y1 )* t
@@ -2110,6 +2112,26 @@ def split(self,i,t=.5) :
2110
2112
x = x1223 + (x2334 - x1223 )* t
2111
2113
y = y1223 + (y2334 - y1223 )* t
2112
2114
return [[P (sp1 [0 ]),P (sp1 [1 ]),P (x12 ,y12 )], [P (x1223 ,y1223 ),P (x ,y ),P (x2334 ,y2334 )], [P (x34 ,y34 ),P (sp2 [1 ]),P (sp2 [2 ])]]
2115
+
2116
+ def split (self ,i ,t = .5 ) :
2117
+ sp1 ,sp2 = self .cp_to_list (i ), self .cp_to_list (i + 1 )
2118
+ return split_seg (sp1 ,sp2 )
2119
+
2120
+ def add_nodes (self , num = None , l = None ) :
2121
+ pass
2122
+
2123
+ def add_nodes_i (self , i , num = None , l = None ) :
2124
+ # Will change total number of points!
2125
+ # Will influence i!!!
2126
+ L = self .l (i )
2127
+ if num == None :
2128
+ num = ceil (L / l )
2129
+ l = L / num
2130
+ sp1 ,sp2 = self .cp_to_list (i ), self .cp_to_list (i + 1 )
2131
+ points = []
2132
+ for j in range (num ) :
2133
+ self .points [i ,i + 2 ] = self .split (i ,self .t_at_l (i ,l ))
2134
+ i += 1
2113
2135
2114
2136
def transform (self , matrix ) :
2115
2137
if matrix == [] : return
@@ -4203,17 +4225,6 @@ def __init__(self):
4203
4225
self .OptionParser .add_option ("" , "--bender-tolerance" , action = "store" , type = "float" , dest = "bender_tolerance" , default = 10. , help = "Bender angle tolerance" )
4204
4226
self .OptionParser .add_option ("" , "--bender-step" , action = "store" , type = "float" , dest = "bender_step" , default = 10. , help = "Bender distance step" )
4205
4227
4206
- if asin (slope .cross (lslope )) < self .options .bender_tolerance :
4207
- lslope = slope
4208
- li = i
4209
- lt = t
4210
- # make bending!
4211
- a = asin (slope .cross (lslope ))
4212
- bend (a , i ,t , li ,lt )
4213
- l += self .options .bender_step
4214
-
4215
-
4216
-
4217
4228
self .OptionParser .add_option ("" , "--in-out-path" , action = "store" , type = "inkbool" , dest = "in_out_path" , default = True , help = "Create in-out paths" )
4218
4229
self .OptionParser .add_option ("" , "--in-out-path-do-not-add-reference-point" , action = "store" , type = "inkbool" , dest = "in_out_path_do_not_add_reference_point" , default = False , help = "Just add reference in-out point" )
4219
4230
self .OptionParser .add_option ("" , "--in-out-path-point-max-dist" , action = "store" , type = "float" , dest = "in_out_path_point_max_dist" , default = 10. , help = "In-out path max distance to reference point" )
@@ -7186,8 +7197,10 @@ def update(self) :
7186
7197
################################################################################
7187
7198
def bender (self ):
7188
7199
def bend (a ,i ,t ,li ,lt ) :
7189
- gcode += "(Push %s mm)" % (subpath .l (i ,t )- subpath .l (li ,lt ))
7190
- gcode += "(Bend %s degrees)" % (asin (a .cross (la ))/ pi * 180 )
7200
+ gcode = ""
7201
+ gcode += "(Push %s mm)\n " % (subpath .l_at_t (i ,t )- subpath .l_at_t (li ,lt ))
7202
+ gcode += "(Bend %s degrees)\n \n " % (a / pi * 180 )
7203
+ return gcode
7191
7204
7192
7205
gcode = ''
7193
7206
if self .selected_paths == {} and self .options .auto_select_paths :
@@ -7197,28 +7210,34 @@ def bend(a,i,t,li,lt) :
7197
7210
paths = self .selected_paths
7198
7211
for layer in self .layers :
7199
7212
if layer in paths :
7213
+ self .set_tool (layer )
7214
+ self .tool = self .tools [layer ][0 ]
7200
7215
for path in paths [layer ] :
7201
7216
csp = CSP (path )
7202
7217
for subpath in csp .items :
7203
7218
# here comes the bender
7219
+ fetch_point (subpath , )
7220
+
7204
7221
gcode += self .tool ['gcode before path' ]+ "\n "
7222
+ #split subpath to len
7205
7223
la = subpath .slope (0 ,0 )
7206
7224
li = 0
7207
7225
lt = 0
7226
+ lslope = None
7208
7227
for i in range (len (subpath .points )- 1 ) :
7209
7228
l = 0
7210
7229
t = 0
7211
7230
while t <= 1 :
7212
7231
lt = t
7213
- t = subpath .t_at_l (self , i , l , self_l = None , tolerance = 0.001 ) :
7232
+ t = subpath .t_at_l (i , l )
7214
7233
slope = subpath .slope (i ,t )
7215
- if asin (slope .cross (lslope )) < self .options .bender_tolerance :
7234
+ if lslope == None or asin (slope .cross (lslope )) < self .options .bender_tolerance :
7216
7235
lslope = slope
7217
7236
li = i
7218
7237
lt = t
7219
7238
# make bending!
7220
7239
a = asin (slope .cross (lslope ))
7221
- bend (a , i ,t , li ,lt )
7240
+ gcode += bend (a , i ,t , li ,lt )
7222
7241
l += self .options .bender_step
7223
7242
#bend at the end of segment
7224
7243
slope = subpath .slope (i ,1 )
@@ -7227,12 +7246,12 @@ def bend(a,i,t,li,lt) :
7227
7246
lt = t
7228
7247
# make bending!
7229
7248
a = asin (slope .cross (lslope ))
7230
- bend (a , i ,t , li ,lt )
7249
+ gcode += bend (a , i ,t , li ,lt )
7231
7250
7232
7251
gcode += self .tool ['gcode after path' ]+ "\n "
7233
-
7234
-
7235
7252
7253
+ if not self .check_dir () : return
7254
+ self .export_gcode (gcode )
7236
7255
7237
7256
7238
7257
################################################################################
@@ -7591,7 +7610,7 @@ def effect(self) :
7591
7610
else :
7592
7611
# Get all Gcodetools data from the scene.
7593
7612
self .get_info ()
7594
- if self .options .active_tab in ['"dxfpoints"' ,'"path-to-gcode"' , '"area_fill"' , '"area"' , '"area_artefacts"' , '"engraving"' , '"lathe"' , '"graffiti"' , '"plasma-prepare-path"' , '"box-prepare-path"' ]:
7613
+ if self .options .active_tab in ['"dxfpoints"' ,'"path-to-gcode"' , '"area_fill"' , '"area"' , '"area_artefacts"' , '"engraving"' , '"lathe"' , '"graffiti"' , '"plasma-prepare-path"' , '"box-prepare-path"' , '"bender"' ]:
7595
7614
if self .orientation_points == {} :
7596
7615
self .error (_ ("Orientation points have not been defined! A default set of orientation points has been automatically added." ),"warning" )
7597
7616
self .orientation ( self .layers [min (1 ,len (self .layers )- 1 )] )
0 commit comments