Skip to content

Commit

Permalink
Ends confusion about conventional/climb milling, sets up boilerplate …
Browse files Browse the repository at this point in the history
…to implement real thing. See vlachoudis#881
  • Loading branch information
Harvie committed Jul 1, 2018
1 parent e08e441 commit aca9b3f
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 5 deletions.
23 changes: 19 additions & 4 deletions CNC.py
Original file line number Diff line number Diff line change
Expand Up @@ -2412,6 +2412,7 @@ def importDXF(self, filename):
li = i
llen = p.length()
longest = opath.pop(li)
if longest._direction(longest.isClosed())==1: longest.invert() #turn path to CCW (conventional when milling outside)

# Can be time consuming
if GCode.LOOP_MERGE:
Expand Down Expand Up @@ -3462,7 +3463,7 @@ def createTabs(self, items, ntabs, dtabs, dx, dy, z):
def reverse(self, items):
undoinfo = []
operation = "reverse"
remove = ["cut","climb","conventional"]
remove = ["cut","climb","conventional","cw","ccw"]
for bid in items:
if self.blocks[bid].name() in ("Header", "Footer"): continue
newpath = []
Expand All @@ -3478,11 +3479,21 @@ def reverse(self, items):
#----------------------------------------------------------------------
def cutDirection(self, items, direction=1):
undoinfo = []

#Right now bCNC can't properly distinguish between climb and conventional, so just do cw/ccw for now
#TODO: We should redirect to CW or CCW based on operation name (wether it's in/pocket or out)
# Conventional = CW for inside profiles and pockets, CCW for outside profiles
# Climb = CCW for inside profiles and pockets, CW for outside profiles
# In such case it's OK to set operation to "conventional/climb", in other cases
# error should be displayed and user should use CW/CCW in other cases this gets very confusing!
if direction==2: direction=1
if direction==-2: direction=-1

if direction==1:
operation = "conventional"
operation = "ccw"
else:
operation = "climb"
remove = ["cut","reverse","climb","conventional"]
operation = "cw"
remove = ["cut","reverse","climb","conventional","cw","ccw"]
for bid in items:
if self.blocks[bid].name() in ("Header", "Footer"): continue
newpath = []
Expand Down Expand Up @@ -3528,8 +3539,10 @@ def profile(self, blocks, offset, overcut=False, name=None, pocket=False):
newname = Block.operationName(path.name, name)
elif offset>0:
newname = Block.operationName(path.name, "out")
if path._direction(path.isClosed())==1: path.invert() #turn path to CCW (conventional when milling outside)
else:
newname = Block.operationName(path.name, "in")
if path._direction(path.isClosed())==-1: path.invert() #turn path to CW (conventional when milling inside)

if not path.isClosed():
m = "Path: '%s' is OPEN"%(path.name)
Expand Down Expand Up @@ -3661,6 +3674,8 @@ def pocket(self, blocks, diameter, stepover, name, nested=False):
# Convert very small arcs to lines
path.convert2Lines(abs(diameter)/10.)

if path._direction(path.isClosed())==-1: path.invert() #turn path to CW (conventional when milling inside)

D = path.direction()
if D==0: D=1
if name is None:
Expand Down
26 changes: 26 additions & 0 deletions EditorPage.py
Original file line number Diff line number Diff line change
Expand Up @@ -481,6 +481,32 @@ def __init__(self, master, app):
tkExtra.Balloon.set(b, _("Reverse cut direction for selected gcode blocks"))
self.addWidget(b)

# ---
col,row=1,0
b = Ribbon.LabelButton(self.frame,
image=Utils.icons["rotate_90"],
text=_("Cut CW"),
compound=LEFT,
anchor=W,
command=lambda s=app:s.insertCommand("DIRECTION CW", True),
background=Ribbon._BACKGROUND)
b.grid(row=row, column=col, padx=0, pady=0, sticky=NSEW)
tkExtra.Balloon.set(b, _("Change cut direction to CW for selected gcode blocks"))
self.addWidget(b)

# ---
row += 1
b = Ribbon.LabelButton(self.frame,
image=Utils.icons["rotate_270"],
text=_("Cut CCW"),
compound=LEFT,
anchor=W,
command=lambda s=app:s.insertCommand("DIRECTION CCW", True),
background=Ribbon._BACKGROUND)
b.grid(row=row, column=col, padx=0, pady=0, sticky=NSEW)
tkExtra.Balloon.set(b, _("Change cut direction to CCW for selected gcode blocks"))
self.addWidget(b)

#===============================================================================
# Info Group
#===============================================================================
Expand Down
6 changes: 5 additions & 1 deletion bCNC.py
Original file line number Diff line number Diff line change
Expand Up @@ -1284,8 +1284,12 @@ def execute(self, line):
# DIR*ECTION
elif rexx.abbrev("DIRECTION", cmd, 3):
if rexx.abbrev("CLIMB", line[1].upper(), 2):
direction = -1
direction = -2
elif rexx.abbrev("CONVENTIONAL", line[1].upper(), 2):
direction = 2
elif rexx.abbrev("CW", line[1].upper(), 2):
direction = -1
elif rexx.abbrev("CCW", line[1].upper(), 2):
direction = 1
else:
tkMessageBox.showerror(_("Direction command error"),
Expand Down

0 comments on commit aca9b3f

Please sign in to comment.