Path: Fix header uniformity and remove trailing whitespace

This PR fixes header uniformity across all Path files. It also removes all trailing whitespace.
This commit is contained in:
luz paz
2020-11-03 13:09:58 -05:00
committed by wwmayer
parent 48365ecdbb
commit b75cd3dd52
231 changed files with 545 additions and 743 deletions

View File

@@ -1,5 +1,6 @@
# -*- coding: utf-8 -*-
# ***************************************************************************
# * Copyright (c) 2015 Dan Falck <ddfalck@gmail.com> *
# * Copyright (c) 2015 Dan Falck <ddfalck@gmail.com> *
# * *
# * This file is part of the FreeCAD CAx development system. *
# * *
@@ -19,7 +20,8 @@
# * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 *
# * USA *
# * *
# ***************************************************************************/
# ***************************************************************************
from __future__ import print_function
import FreeCAD
from FreeCAD import Units

View File

@@ -1,7 +1,5 @@
# -*- coding: utf-8 -*-
# ***************************************************************************
# * *
# * Copyright (c) 2015 Dan Falck <ddfalck@gmail.com> *
# * *
# * This program is free software; you can redistribute it and/or modify *
@@ -21,11 +19,12 @@
# * USA *
# * *
# ***************************************************************************
import FreeCAD
import Path
import PathScripts.PostUtils as PostUtils
TOOLTIP = ''' Example Post, using Path.Commands instead of Path.toGCode strings for Path gcode output. '''
TOOLTIP = '''Example Post, using Path.Commands instead of Path.toGCode strings for Path gcode output.'''
SHOW_EDITOR = True

View File

@@ -1,5 +1,5 @@
# ***************************************************************************
# * (c) sliptonic (shopinthewoods@gmail.com) 2014 *
# * Copyright (c) 2014 sliptonic <shopinthewoods@gmail.com> *
# * *
# * This file is part of the FreeCAD CAx development system. *
# * *
@@ -19,7 +19,8 @@
# * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 *
# * USA *
# * *
# ***************************************************************************/
# ***************************************************************************
from __future__ import print_function
TOOLTIP='''

View File

@@ -1,5 +1,5 @@
# ***************************************************************************
# * (c) sliptonic (shopinthewoods@gmail.com) 2014 *
# * Copyright (c) 2014 sliptonic <shopinthewoods@gmail.com> *
# * *
# * This file is part of the FreeCAD CAx development system. *
# * *

View File

@@ -1,5 +1,5 @@
# ***************************************************************************
# * (c) Yorik van Havre (yorik@uncreated.net) 2014 *
# * Copyright (c) 2014 Yorik van Havre <yorik@uncreated.net> *
# * *
# * This file is part of the FreeCAD CAx development system. *
# * *
@@ -19,7 +19,8 @@
# * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 *
# * USA *
# * *
# ***************************************************************************/
# ***************************************************************************
from __future__ import print_function
TOOLTIP='''

View File

@@ -1,5 +1,5 @@
# ***************************************************************************
# * (c) Yorik van Havre (yorik@uncreated.net) 2014 *
# * Copyright (c) 2014 Yorik van Havre <yorik@uncreated.net> *
# * *
# * This file is part of the FreeCAD CAx development system. *
# * *
@@ -19,7 +19,7 @@
# * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 *
# * USA *
# * *
# ***************************************************************************/
# ***************************************************************************
'''

View File

@@ -1,8 +1,8 @@
# ***************************************************************************
# * (c) imarin 2017 *
# * Copyright (c) 2017 imarin *
# * *
# * heavily based on gbrl post-procesor by: *
# * (c) sliptonic (shopinthewoods@gmail.com) 2014 *
# * Heavily based on gbrl post-procesor by: *
# * Copyright (c) 2014 sliptonic <shopinthewoods@gmail.com> *
# * *
# * This file is part of the FreeCAD CAx development system. *
# * *
@@ -22,7 +22,7 @@
# * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 *
# * USA *
# * *
# ***************************************************************************/
# ***************************************************************************
import datetime
from PathScripts import PostUtils

View File

@@ -1,5 +1,5 @@
# ***************************************************************************
# * (c) Yorik van Havre (yorik@uncreated.net) 2014 *
# * Copyright (c) 2014 Yorik van Havre <yorik@uncreated.net> *
# * *
# * This file is part of the FreeCAD CAx development system. *
# * *

View File

@@ -1,9 +1,8 @@
# -*- coding: utf-8 -*-
# ***************************************************************************
# * *
# * (c) sliptonic (shopinthewoods@gmail.com) 2014 *
# * (c) Gauthier Briere - 2018, 2019 *
# * (c) Schildkroet - 2019-2020 *
# * Copyright (c) 2014 sliptonic <shopinthewoods@gmail.com> *
# * Copyright (c) 2018, 2019 Gauthier Briere *
# * Copyright (c) 2019, 2020 Schildkroet *
# * *
# * This file is part of the FreeCAD CAx development system. *
# * *
@@ -23,7 +22,7 @@
# * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 *
# * USA *
# * *
# ***************************************************************************/
# ***************************************************************************
import FreeCAD
from FreeCAD import Units
@@ -220,7 +219,7 @@ def export(objectslist, filename, argstring):
gcode += linenumber() + "(Exported by FreeCAD)\n"
gcode += linenumber() + "(Post Processor: " + __name__ + ")\n"
gcode += linenumber() + "(Output Time:" + str(datetime.datetime.now()) + ")\n"
# Check canned cycles for drilling
if TRANSLATE_DRILL_CYCLES:
if len(SUPPRESS_COMMANDS) == 0:
@@ -259,7 +258,7 @@ def export(objectslist, filename, argstring):
if not hasattr(obj, "Path"):
print("The object " + obj.Name + " is not a path. Please select only path and Compounds.")
return
# Skip inactive operations
if PathUtil.opProperty(obj, 'Active') is False:
continue
@@ -273,7 +272,7 @@ def export(objectslist, filename, argstring):
gcode += linenumber() + "(Begin operation: " + obj.Label + ")\n"
for line in PRE_OPERATION.splitlines(True):
gcode += linenumber() + line
# get coolant mode
coolantMode = 'None'
if hasattr(obj, "CoolantMode") or hasattr(obj, 'Base') and hasattr(obj.Base, "CoolantMode"):
@@ -431,7 +430,7 @@ def parse(pathobj):
if command in ('G90', 'G91'):
MOTION_MODE = command
if TRANSLATE_DRILL_CYCLES:
if command in ('G81', 'G82', 'G83'):
@@ -503,12 +502,12 @@ def drill_translate(outstring, cmd, params):
if RETRACT_Z < drill_Z :
trBuff += linenumber() + "(drill cycle error: R less than Z )\n"
return trBuff
if MOTION_MODE == 'G91': # G91 relative movements
drill_X += CURRENT_X
drill_Y += CURRENT_Y
drill_Z += CURRENT_Z
RETRACT_Z += CURRENT_Z
drill_X += CURRENT_X
drill_Y += CURRENT_Y
drill_Z += CURRENT_Z
RETRACT_Z += CURRENT_Z
if DRILL_RETRACT_MODE == 'G98' and CURRENT_Z >= RETRACT_Z:
RETRACT_Z = CURRENT_Z
@@ -530,16 +529,16 @@ def drill_translate(outstring, cmd, params):
strF_Feedrate = ' F' + format(float(drill_feedrate.getValueAs(UNIT_SPEED_FORMAT)), '.2f') + "\n"
print (strF_Feedrate)
# preliminary mouvement(s)
# preliminary mouvement(s)
if CURRENT_Z < RETRACT_Z:
trBuff += linenumber() + strG0_RETRACT_Z
trBuff += linenumber() + 'G0 X' + format(float(drill_X.getValueAs(UNIT_FORMAT)), strFormat) + ' Y' + format(float(drill_Y.getValueAs(UNIT_FORMAT)), strFormat) + "\n"
if CURRENT_Z > RETRACT_Z:
# NIST GCODE 3.5.16.1 Preliminary and In-Between Motion says G0 to RETRACT_Z. Here use G1 since retract height may be below surface !
trBuff += linenumber() + 'G1 Z' + format(float(RETRACT_Z.getValueAs(UNIT_FORMAT)), strFormat) + strF_Feedrate
trBuff += linenumber() + 'G1 Z' + format(float(RETRACT_Z.getValueAs(UNIT_FORMAT)), strFormat) + strF_Feedrate
last_Stop_Z = RETRACT_Z
# drill moves
# drill moves
if cmd in ('G81', 'G82'):
trBuff += linenumber() + 'G1 Z' + format(float(drill_Z.getValueAs(UNIT_FORMAT)), strFormat) + strF_Feedrate
# pause where applicable
@@ -551,7 +550,7 @@ def drill_translate(outstring, cmd, params):
while 1:
if last_Stop_Z != RETRACT_Z :
clearance_depth = last_Stop_Z + a_bit # rapid move to just short of last drilling depth
trBuff += linenumber() + 'G0 Z' + format(float(clearance_depth.getValueAs(UNIT_FORMAT)) , strFormat) + "\n"
trBuff += linenumber() + 'G0 Z' + format(float(clearance_depth.getValueAs(UNIT_FORMAT)) , strFormat) + "\n"
next_Stop_Z = last_Stop_Z - drill_Step
if next_Stop_Z > drill_Z:
trBuff += linenumber() + 'G1 Z' + format(float(next_Stop_Z.getValueAs(UNIT_FORMAT)), strFormat) + strF_Feedrate
@@ -561,10 +560,10 @@ def drill_translate(outstring, cmd, params):
trBuff += linenumber() + 'G1 Z' + format(float(drill_Z.getValueAs(UNIT_FORMAT)), strFormat) + strF_Feedrate
trBuff += linenumber() + strG0_RETRACT_Z
break
except Exception as e:
pass
if MOTION_MODE == 'G91':
trBuff += linenumber() + 'G91' # Restore if changed

View File

@@ -1,9 +1,5 @@
# -*- coding: UTF-8 -*-
#***************************************************************************
#* *
#* heidenhain_post.py HEDENHAIN Post-Processor for FreeCAD *
#* *
#* Copyright (C) 2020 Stefano Chiaro <stefano.chiaro@yahoo.com> *
#* *
#* This library is free software; you can redistribute it and/or *
@@ -22,6 +18,8 @@
#* 02110-1301 USA *
#***************************************************************************
# HEDENHAIN Post-Processor for FreeCAD
import FreeCAD
from FreeCAD import Units
import argparse
@@ -219,7 +217,7 @@ def processArguments(argstring):
global FIRST_LBL
global SHOW_EDITOR
global SKIP_WARNS
try:
args = parser.parse_args(shlex.split(argstring))
if args.skip_params:
@@ -248,7 +246,7 @@ def processArguments(argstring):
return False
return True
def export(objectslist, filename, argstring):
if not processArguments(argstring):
return None
@@ -261,7 +259,7 @@ def export(objectslist, filename, argstring):
global STORED_COMPENSATED_OBJ
global COMPENSATION_DIFF_STATUS
global LBLIZE_STAUS
Object_Kind = None
Feed_Rapid = False
Feed = 0
@@ -275,7 +273,7 @@ def export(objectslist, filename, argstring):
'I', 'J', 'K',
'F', 'H', 'S', 'T', 'Q', 'R', 'L'
]
for obj in objectslist:
if not hasattr(obj, "Path"):
print(
@@ -289,7 +287,7 @@ def export(objectslist, filename, argstring):
for obj in objectslist:
Cmd_Count = 0 # command line number
LBLIZE_STAUS = False
# useful to get idea of object kind
if isinstance (obj.Proxy, PathScripts.PathToolController.ToolController):
Object_Kind = "TOOL"
@@ -305,7 +303,7 @@ def export(objectslist, filename, argstring):
if LBLIZE_ACTIVE: LBLIZE_STAUS = True
elif isinstance (obj.Proxy, PathScripts.PathHelix.ObjectHelix):
Object_Kind = "HELIX"
# If used compensated path, store, recompute and diff when asked
if hasattr(obj, 'UseComp') and SOLVE_COMPENSATION_ACTIVE:
if obj.UseComp:
@@ -313,7 +311,7 @@ def export(objectslist, filename, argstring):
# Take a copy of compensated path
STORED_COMPENSATED_OBJ = obj.Path.Commands
# Find mill compensation
if hasattr(obj, 'Side') and hasattr(obj, 'Direction'):
if hasattr(obj, 'Side') and hasattr(obj, 'Direction'):
if obj.Side == "Outside" and obj.Direction == "CW":
Compensation = "L"
elif obj.Side == "Outside" and obj.Direction == "CCW":
@@ -358,8 +356,8 @@ def export(objectslist, filename, argstring):
)
# we can try to solve compensation
POSTGCODE.append("; COMPENSATION ACTIVE")
COMPENSATION_DIFF_STATUS[0] = True
COMPENSATION_DIFF_STATUS[0] = True
for c in obj.Path.Commands:
Cmd_Count += 1
outstring = []
@@ -378,23 +376,23 @@ def export(objectslist, filename, argstring):
Spindle_RPM = c.Parameters['S'] # Could be deleted if tool it's OK
elif param == 'T':
ToolId = c.Parameters['T'] # Could be deleted if tool it's OK
if command == 'G90':
G_FUNCTION_STORE['G90'] = True
G_FUNCTION_STORE['G91'] = False
if command == 'G91':
G_FUNCTION_STORE['G91'] = True
G_FUNCTION_STORE['G90'] = False
if command == 'G98':
G_FUNCTION_STORE['G98'] = True
G_FUNCTION_STORE['G99'] = False
if command == 'G99':
G_FUNCTION_STORE['G99'] = True
G_FUNCTION_STORE['G98'] = False
# Rapid movement
if command == 'G0':
Spindle_Status = ""
@@ -411,7 +409,7 @@ def export(objectslist, filename, argstring):
c.Parameters, Compensation, Feed, True, Spindle_Status, Cmd_Count
)
if parsedElem != None: POSTGCODE.append(parsedElem)
# Linear movement
if command == 'G1':
parsedElem = HEIDEN_Line(
@@ -426,12 +424,12 @@ def export(objectslist, filename, argstring):
)
if parsedElem != None:
POSTGCODE.extend(parsedElem)
if command == 'G80': #Reset Canned Cycles
G_FUNCTION_STORE['G81'] = False
G_FUNCTION_STORE['G82'] = False
G_FUNCTION_STORE['G83'] = False
# Drilling, Dwell Drilling, Peck Drilling
if command == 'G81' or command == 'G82' or command == 'G83':
parsedElem = HEIDEN_Drill(
@@ -439,21 +437,21 @@ def export(objectslist, filename, argstring):
)
if parsedElem != None:
POSTGCODE.extend(parsedElem)
# Tool change
if command == 'M6':
parsedElem = HEIDEN_ToolCall(obj)
if parsedElem != None: POSTGCODE.append(parsedElem)
if COMPENSATION_DIFF_STATUS[0]: #Restore the compensation if removed
obj.UseComp = True
obj.recompute()
COMPENSATION_DIFF_STATUS[0] = False
if LBLIZE_STAUS:
HEIDEN_LBL_Replace()
LBLIZE_STAUS = False
if LBLIZE_ACTIVE:
if not SKIP_WARNS: (
PostUtils.editor(
@@ -467,9 +465,9 @@ def export(objectslist, filename, argstring):
)
POSTGCODE.append(HEIDEN_End(objectslist)) #add footer
Program_Out = HEIDEN_Numberize(POSTGCODE) #add line number
if SHOW_EDITOR: PostUtils.editor(Program_Out)
gfile = pythonopen(filename, "w")
gfile.write(Program_Out)
gfile.close()
@@ -491,7 +489,7 @@ def HEIDEN_End(ActualJob): #use Label for program name
else:
program_id = "NEW"
return "END PGM " + program_id + " " + UNITS
#def HEIDEN_ToolDef(tool_id, tool_lenght, tool_radius): # old machines don't have tool table, need tooldef list
# return "TOOL DEF " + tool_id + " R" + "{:.3f}".format(tool_lenght) + " L" + "{:.3f}".format(tool_radius)
@@ -502,7 +500,7 @@ def HEIDEN_ToolCall(tool_Params):
H_Tool_ID = "0"
H_Tool_Speed = 0
H_Tool_Comment = ""
if hasattr(tool_Params, "Label"): # use Label as tool comment
H_Tool_Comment = tool_Params.Label
if hasattr(tool_Params, "SpindleDir"): # get spindle direction for this tool
@@ -523,7 +521,7 @@ def HEIDEN_ToolCall(tool_Params):
HEIDEN_Format(" S", H_Tool_Speed) + " ;" + str(H_Tool_Comment)
)
# create a linear movement
# create a linear movement
def HEIDEN_Line(line_Params, line_comp, line_feed, line_rapid, line_M_funct, Cmd_Number):
global FEED_MAX_SPEED
global COMPENSATION_DIFF_STATUS
@@ -543,7 +541,7 @@ def HEIDEN_Line(line_Params, line_comp, line_feed, line_rapid, line_M_funct, Cmd
}
H_Line = "L"
H_Line_Params = [['X', 'Y', 'Z'], ['R0', line_feed, line_M_funct]]
# check and hide duplicated axis movements, not last, update with new ones
for i in H_Line_New:
if G_FUNCTION_STORE['G91']: # incremental
@@ -559,10 +557,10 @@ def HEIDEN_Line(line_Params, line_comp, line_feed, line_rapid, line_M_funct, Cmd
if line_Params[i] != H_Line_New[i] or line_M_funct != '':
H_Line += " " + HEIDEN_Format(i, line_Params[i])
H_Line_New[i] = line_Params[i]
if H_Line == "L": #No movements no line
return None
if COMPENSATION_DIFF_STATUS[0]: # Diff from compensated ad not compensated path
if COMPENSATION_DIFF_STATUS[1]: # skip if already compensated, not active by now
Cmd_Number -= 1 # align
@@ -578,13 +576,13 @@ def HEIDEN_Line(line_Params, line_comp, line_feed, line_rapid, line_M_funct, Cmd
# COMPENSATION_DIFF_STATUS[1] = False
else:
H_Line_Params[1][0] = "R" + line_comp # not used by now
# check if we need to skip already active parameters
# R parameter
if MACHINE_SKIP_PARAMS == False or H_Line_Params[1][0] != MACHINE_STORED_PARAMS[0]:
MACHINE_STORED_PARAMS[0] = H_Line_Params[1][0]
H_Line += " " + H_Line_Params[1][0]
# F parameter (check rapid o feed)
if line_rapid == True: H_Line_Params[1][1] = FEED_MAX_SPEED
if MACHINE_USE_FMAX == True and line_rapid == True:
@@ -593,12 +591,12 @@ def HEIDEN_Line(line_Params, line_comp, line_feed, line_rapid, line_M_funct, Cmd
if MACHINE_SKIP_PARAMS == False or H_Line_Params[1][1] != MACHINE_STORED_PARAMS[1]:
MACHINE_STORED_PARAMS[1] = H_Line_Params[1][1]
H_Line += HEIDEN_Format(" F", H_Line_Params[1][1])
# M parameter
if MACHINE_SKIP_PARAMS == False or H_Line_Params[1][2] != MACHINE_STORED_PARAMS[2]:
MACHINE_STORED_PARAMS[2] = H_Line_Params[1][2]
H_Line += " M" + H_Line_Params[1][2]
# LBLIZE check and array creation
if LBLIZE_STAUS:
i = H_Line_Params[0][MACHINE_WORK_AXIS]
@@ -607,11 +605,11 @@ def HEIDEN_Line(line_Params, line_comp, line_feed, line_rapid, line_M_funct, Cmd
HEIDEN_LBL_Get(MACHINE_LAST_POSITION, H_Line_New[i])
else:
HEIDEN_LBL_Get()
# update machine position with new values
for i in H_Line_New:
MACHINE_LAST_POSITION[i] = H_Line_New[i]
return H_Line
# create a arc movement
@@ -641,7 +639,7 @@ def HEIDEN_Arc(arc_Params, arc_direction, arc_comp, arc_feed, arc_rapid, arc_M_f
'Y': 99999,
'Z': 99999
}
# get command values
if G_FUNCTION_STORE['G91']: # incremental
H_ArcIncr = "I"
@@ -673,7 +671,7 @@ def HEIDEN_Arc(arc_Params, arc_direction, arc_comp, arc_feed, arc_rapid, arc_M_f
if b in arc_Params:
# to change if I J K are not always incremental
H_Arc_CC[a] = H_Arc_CC[a] + arc_Params[b]
def Axis_Select(a, b, c, incr):
if a in arc_Params and b in arc_Params:
_H_ArcCenter = (
@@ -693,7 +691,7 @@ def HEIDEN_Arc(arc_Params, arc_direction, arc_comp, arc_feed, arc_rapid, arc_M_f
return [_H_ArcCenter, _H_ArcPoint]
else:
return ["", ""]
# set the right work plane based on tool direction
if MACHINE_WORK_AXIS == 0: # tool on X axis
Axis_Result = Axis_Select('Y', 'Z', 'X', H_ArcIncr)
@@ -707,7 +705,7 @@ def HEIDEN_Arc(arc_Params, arc_direction, arc_comp, arc_feed, arc_rapid, arc_M_f
if H_ArcCenter == "CC ": #No movements no circle
return None
if arc_direction == "G2": # set the right arc direction
H_ArcPoint += " DR-"
else:
@@ -728,12 +726,12 @@ def HEIDEN_Arc(arc_Params, arc_direction, arc_comp, arc_feed, arc_rapid, arc_M_f
H_Arc_Params[1][0] = "R" + arc_comp # not used by now
# check if we need to skip already active parameters
# R parameter
if MACHINE_SKIP_PARAMS == False or H_Arc_Params[1][0] != MACHINE_STORED_PARAMS[0]:
MACHINE_STORED_PARAMS[0] = H_Arc_Params[1][0]
H_ArcPoint += " " + H_Arc_Params[1][0]
# F parameter
if arc_rapid == True: H_Arc_Params[1][1] = FEED_MAX_SPEED
if MACHINE_USE_FMAX == True and arc_rapid == True:
@@ -742,7 +740,7 @@ def HEIDEN_Arc(arc_Params, arc_direction, arc_comp, arc_feed, arc_rapid, arc_M_f
if MACHINE_SKIP_PARAMS == False or H_Arc_Params[1][1] != MACHINE_STORED_PARAMS[1]:
MACHINE_STORED_PARAMS[1] = H_Arc_Params[1][1]
H_ArcPoint += HEIDEN_Format(" F", H_Arc_Params[1][1])
# M parameter
if MACHINE_SKIP_PARAMS == False or H_Arc_Params[1][2] != MACHINE_STORED_PARAMS[2]:
MACHINE_STORED_PARAMS[2] = H_Arc_Params[1][2]
@@ -753,7 +751,7 @@ def HEIDEN_Arc(arc_Params, arc_direction, arc_comp, arc_feed, arc_rapid, arc_M_f
for i in H_Arc_Params[0]:
H_Arc_P_NEW[i] = MACHINE_LAST_POSITION[i] + H_Arc_P_NEW[i]
H_Arc_CC[i] = MACHINE_LAST_POSITION[i] + H_Arc_CC[i]
# check if we can skip CC print
if(
MACHINE_LAST_CENTER['X'] == H_Arc_CC['X'] and
@@ -761,7 +759,7 @@ def HEIDEN_Arc(arc_Params, arc_direction, arc_comp, arc_feed, arc_rapid, arc_M_f
MACHINE_LAST_CENTER['Z'] == H_Arc_CC['Z']
):
H_ArcSameCenter = True
# LBLIZE check and array creation
if LBLIZE_STAUS:
i = H_Arc_Params[0][MACHINE_WORK_AXIS]
@@ -773,29 +771,29 @@ def HEIDEN_Arc(arc_Params, arc_direction, arc_comp, arc_feed, arc_rapid, arc_M_f
HEIDEN_LBL_Get(MACHINE_LAST_POSITION, H_Arc_P_NEW[i], 1)
else:
HEIDEN_LBL_Get()
# update machine position with new values
for i in H_Arc_Params[0]:
MACHINE_LAST_CENTER[i] = H_Arc_CC[i]
MACHINE_LAST_POSITION[i] = H_Arc_P_NEW[i]
# if the circle center is already the same we don't need to print it
if H_ArcSameCenter:
return [H_ArcPoint]
else:
return [H_ArcCenter, H_ArcPoint]
def HEIDEN_PolarArc(pol_cc_X, pol_cc_Y, pol_X, pol_Y, pol_Z, pol_Axis, pol_Incr):
pol_Angle = 0
pol_Result = ""
# get delta distance form point to circle center
delta_X = pol_X - pol_cc_X
delta_Y = pol_Y - pol_cc_Y
# prevent undefined result of atan
if delta_X != 0 or delta_Y != 0:
pol_Angle = math.degrees(math.atan2(delta_X, delta_Y))
# set the appropriate zero and direction of angle
# with X axis zero have the Y+ direction
if pol_Axis == "X":
@@ -806,16 +804,16 @@ def HEIDEN_PolarArc(pol_cc_X, pol_cc_Y, pol_X, pol_Y, pol_Z, pol_Axis, pol_Incr)
# with Z axis zero have the X+ direction
elif pol_Axis == "Z":
pol_Angle = 90 - pol_Angle
# set inside +0° +360° range
if pol_Angle > 0:
if pol_Angle >= 360: pol_Angle = pol_Angle - 360
elif pol_Angle < 0:
pol_Angle = pol_Angle + 360
if pol_Angle < 0: pol_Angle = pol_Angle + 360
pol_Result = "P" + HEIDEN_Format(" PA+", pol_Angle) + " " + pol_Incr + HEIDEN_Format(pol_Axis, pol_Z)
return pol_Result
def HEIDEN_Drill(drill_Obj, drill_Params, drill_Type, drill_feed): # create a drill cycle and movement
@@ -830,12 +828,12 @@ def HEIDEN_Drill(drill_Obj, drill_Params, drill_Type, drill_feed): # create a dr
drill_Surface = None
drill_SafePoint = 0
drill_StartPoint = 0
# try to get the distance from Clearance Height and Start Depth
if hasattr(drill_Obj, 'StartDepth') and hasattr(drill_Obj.StartDepth, 'Value'):
drill_Surface = drill_Obj.StartDepth.Value
# initialize
# initialize
if 'R' in drill_Params:
# SafePoint equals to R position
if G_FUNCTION_STORE['G91']: # incremental
@@ -849,16 +847,16 @@ def HEIDEN_Drill(drill_Obj, drill_Params, drill_Type, drill_feed): # create a dr
else:
drill_Defs['DIST'] = 0
drill_StartPoint = drill_SafePoint
if 'Z' in drill_Params:
if G_FUNCTION_STORE['G91']: # incremental
drill_Defs['DEPTH'] = drill_SafePoint + drill_Params['Z']
else:
drill_Defs['DEPTH'] = drill_Params['Z'] - drill_StartPoint
if drill_Defs['DEPTH'] > 0:
drill_Output.append("; WARNING START DEPTH LOWER THAN FINAL DEPTH")
drill_Defs['INCR'] = drill_Defs['DEPTH']
# overwrite
if 'P' in drill_Params: drill_Defs['DWELL'] = drill_Params['P']
@@ -875,16 +873,16 @@ def HEIDEN_Drill(drill_Obj, drill_Params, drill_Type, drill_feed): # create a dr
drill_Rapid = HEIDEN_Format(" F", FEED_MAX_SPEED)
else:
drill_Rapid = " R0" + HEIDEN_Format(" F", FEED_MAX_SPEED) + " M"
# move to drill location
drill_Movement = "L"
if G_FUNCTION_STORE['G91']: # incremental
# update Z value to R + actual_Z if first call
if G_FUNCTION_STORE[drill_Type] == False:
if G_FUNCTION_STORE[drill_Type] == False:
MACHINE_LAST_POSITION['Z'] = drill_Defs['DIST'] + MACHINE_LAST_POSITION['Z']
drill_Movement = "L" + HEIDEN_Format(" Z", MACHINE_LAST_POSITION['Z']) + drill_Rapid
drill_Output.append(drill_Movement)
# update X and Y position
if 'X' in drill_Params and drill_Params['X'] != 0:
MACHINE_LAST_POSITION['X'] = drill_Params['X'] + MACHINE_LAST_POSITION['X']
@@ -900,7 +898,7 @@ def HEIDEN_Drill(drill_Obj, drill_Params, drill_Type, drill_feed): # create a dr
drill_Movement = "L" + HEIDEN_Format(" Z", drill_SafePoint) + drill_Rapid
drill_Output.append(drill_Movement)
MACHINE_LAST_POSITION['Z'] = drill_SafePoint
# update X and Y position
if 'X' in drill_Params and drill_Params['X'] != MACHINE_LAST_POSITION['X']:
MACHINE_LAST_POSITION['X'] = drill_Params['X']
@@ -916,16 +914,16 @@ def HEIDEN_Drill(drill_Obj, drill_Params, drill_Type, drill_feed): # create a dr
drill_Movement = "L" + HEIDEN_Format(" Z", drill_SafePoint) + drill_Rapid
drill_Output.append(drill_Movement)
MACHINE_LAST_POSITION['Z'] = drill_SafePoint
# check if cycle is already stored
i = True
for j in drill_Defs:
if drill_Defs[j] != STORED_CANNED_PARAMS[j]: i = False
if i == False: # not same cycle, update and print
for j in drill_Defs:
STORED_CANNED_PARAMS[j] = drill_Defs[j]
# get the DEF template and replace the strings
drill_CycleDef = MACHINE_CYCLE_DEF[1].format(
DIST = str("{:.3f}".format(drill_Defs['DIST'])),
@@ -935,13 +933,13 @@ def HEIDEN_Drill(drill_Obj, drill_Params, drill_Type, drill_feed): # create a dr
FEED = str("{:.0f}".format(drill_Defs['FEED']))
)
drill_Output.extend(drill_CycleDef.split("\n"))
# add the cycle call to do the drill
if MACHINE_SKIP_PARAMS:
drill_Output.append("CYCL CALL")
else:
drill_Output.append("CYCL CALL M")
# set already active cycle, to do: check changes and movements until G80
G_FUNCTION_STORE[drill_Type] = True
@@ -952,7 +950,7 @@ def HEIDEN_Format(formatType, formatValue):
global FEED_DECIMALS
global AXIS_DECIMALS
returnString = ""
formatType = str(formatType)
if formatType == "S" or formatType == " S":
returnString = '%.*f' % (SPINDLE_DECIMALS, formatValue)
@@ -998,12 +996,12 @@ def HEIDEN_LBL_Get(GetPoint=None, GetLevel=None, GetAddit=0):
if len(STORED_LBL) != 0 and len(STORED_LBL[-1][-1]) != 0:
STORED_LBL[-1].append([])
return
def HEIDEN_LBL_Replace():
global POSTGCODE
global STORED_LBL
global FIRST_LBL
Gcode_Lenght = len(POSTGCODE)
# this function look inside strings to find and replace it with LBL
@@ -1011,7 +1009,7 @@ def HEIDEN_LBL_Replace():
# until the "Z" axis is moved or rapid movements are performed
# these "planar with feed movements" create a new row with
# the index of start and end POSTGCODE line
# to LBLize we need to diff with the first column backward
# to LBLize we need to diff with the first column backward
# from the last row in the last column of indexes
Cols = len(STORED_LBL) - 1
if Cols > 0:

View File

@@ -1,5 +1,5 @@
# ***************************************************************************
# * (c) sliptonic (shopinthewoods@gmail.com) 2018 *
# * Copyright (c) 2018 sliptonic <shopinthewoods@gmail.com> *
# * *
# * This file is part of the FreeCAD CAx development system. *
# * *
@@ -19,7 +19,8 @@
# * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 *
# * USA *
# * *
# ***************************************************************************/
# ***************************************************************************
from __future__ import print_function
import FreeCAD
from FreeCAD import Units

View File

@@ -1,5 +1,5 @@
# ***************************************************************************
# * (c) sliptonic (shopinthewoods@gmail.com) 2014 *
# * Copyright (c) 2014 sliptonic <shopinthewoods@gmail.com> *
# * *
# * This file is part of the FreeCAD CAx development system. *
# * *
@@ -19,7 +19,8 @@
# * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 *
# * USA *
# * *
# ***************************************************************************/
# ***************************************************************************
from __future__ import print_function
import FreeCAD
from FreeCAD import Units

View File

@@ -1,5 +1,5 @@
# ***************************************************************************
# * (c) sliptonic (shopinthewoods@gmail.com) 2014 *
# * Copyright (c) 2014 sliptonic <shopinthewoods@gmail.com> *
# * *
# * This file is part of the FreeCAD CAx development system. *
# * *
@@ -64,7 +64,7 @@ OUTPUT_HEADER = True
OUTPUT_LINE_NUMBERS = False
SHOW_EDITOR = True
MODAL = False # if true commands are suppressed if the same as previous line.
USE_TLO = True # if true G43 will be output following tool changes
USE_TLO = True # if true G43 will be output following tool changes
OUTPUT_DOUBLES = True # if false duplicate axis values are suppressed if the same as previous line.
COMMAND_SPACE = " "
LINENR = 100 # line number starting value
@@ -188,7 +188,7 @@ def export(objectslist, filename, argstring):
for obj in objectslist:
# Skip inactive operations
if hasattr(obj, 'Active'):
if hasattr(obj, 'Active'):
if not obj.Active:
continue
if hasattr(obj, 'Base') and hasattr(obj.Base, 'Active'):
@@ -255,7 +255,7 @@ def export(objectslist, filename, argstring):
# turn coolant off if required
if not coolantMode == 'None':
if OUTPUT_COMMENTS:
gcode += linenumber() + '(Coolant Off:' + coolantMode + ')\n'
gcode += linenumber() + '(Coolant Off:' + coolantMode + ')\n'
gcode += linenumber() +'M9' + '\n'
# do the post_amble
@@ -338,12 +338,12 @@ def parse(pathobj):
if hasattr(pathobj.ToolController, 'HorizRapid') and pathobj.ToolController.HorizRapid > 0:
opHorizRapid = Units.Quantity(pathobj.ToolController.HorizRapid, FreeCAD.Units.Velocity)
else:
FreeCAD.Console.PrintWarning('Tool Controller Horizontal Rapid Values are unset'+ '\n')
FreeCAD.Console.PrintWarning('Tool Controller Horizontal Rapid Values are unset'+ '\n')
if hasattr(pathobj.ToolController, 'VertRapid') and pathobj.ToolController.VertRapid > 0:
opVertRapid = Units.Quantity(pathobj.ToolController.VertRapid, FreeCAD.Units.Velocity)
else:
FreeCAD.Console.PrintWarning('Tool Controller Vertical Rapid Values are unset'+ '\n')
FreeCAD.Console.PrintWarning('Tool Controller Vertical Rapid Values are unset'+ '\n')
for c in pathobj.Path.Commands:
@@ -355,8 +355,8 @@ def parse(pathobj):
command = 'G1'
else:
outstring.append('(Tool Controller Rapid Values are unset)' + '\n')
outstring.append(command)
# if modal: suppress the command if it is the same as the last one
@@ -392,7 +392,7 @@ def parse(pathobj):
pos = Units.Quantity(c.Parameters[param], FreeCAD.Units.Length)
outstring.append(
param + format(float(pos.getValueAs(UNIT_FORMAT)), precision_string))
if adaptiveOp and c.Name in ["G0", "G00"]:
if opHorizRapid and opVertRapid:
if 'Z' not in c.Parameters:

View File

@@ -1,9 +1,5 @@
from __future__ import print_function
import datetime
from PathScripts import PostUtils
# ***************************************************************************
# * (c) sliptonic (shopinthewoods@gmail.com) 2014 *
# * Copyright (c) 2014 sliptonic <shopinthewoods@gmail.com> *
# * *
# * This file is part of the FreeCAD CAx development system. *
# * *
@@ -23,7 +19,11 @@ from PathScripts import PostUtils
# * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 *
# * USA *
# * *
# ***************************************************************************/
# ***************************************************************************
from __future__ import print_function
import datetime
from PathScripts import PostUtils
TOOLTIP = '''

View File

@@ -1,5 +1,6 @@
# -*- coding: utf-8 -*-
# ***************************************************************************
# * (c) sliptonic (shopinthewoods<at>gmail.com) 2014 *
# * Copyright (c) 2014 sliptonic <shopinthewoods<at>gmail.com> *
# * *
# * This file is part of the FreeCAD CAx development system. *
# * *
@@ -19,7 +20,7 @@
# * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 *
# * USA *
# * *
# ***************************************************************************/
# ***************************************************************************
'''
This is a preprocessor file for the Path workbench. Its aim is to

View File

@@ -1,7 +1,5 @@
# -*- coding: utf-8 -*-
#***************************************************************************
#* *
#* Copyright (c) 2016 Christoph Blaue <blaue@fh-westkueste.de> *
#* *
#* This program is free software; you can redistribute it and/or modify *
@@ -191,7 +189,7 @@ SPINDLE_DECIMALS = 0
SUPPRESS_ZERO_FEED = True
# possible values: True if feed is zero the F command is suppressed
# False F commands are written even if they are zero
# This is useful for machines without special speeds for the G0 command. They could be
# This is useful for machines without special speeds for the G0 command. They could be
# left zero and are suppressed in the output
# The header is divided into two parts, one is dynamic, the other is a static GCode header.

View File

@@ -1,5 +1,5 @@
#***************************************************************************
#* (c) Jon Nordby (jononor@gmail.com) 2015 *
#* Copyright (c) 2015 Jon Nordby <jononor@gmail.com> *
#* *
#* This file is part of the FreeCAD CAx development system. *
#* *
@@ -19,7 +19,7 @@
#* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 *
#* USA *
#* *
#***************************************************************************/
#***************************************************************************
TOOLTIP='''

View File

@@ -1,5 +1,5 @@
# ***************************************************************************
# * (c) Yorik van Havre (yorik@uncreated.net) 2015 *
# * Copyright (c) 2015 Yorik van Havre <yorik@uncreated.net> *
# * *
# * This file is part of the FreeCAD CAx development system. *
# * *
@@ -19,7 +19,7 @@
# * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 *
# * USA *
# * *
# ***************************************************************************/
# ***************************************************************************
'''
This is an preprocessor to read gcode files produced from slic3r.

View File

@@ -1,5 +1,5 @@
# ***************************************************************************
# * (c) sliptonic (shopinthewoods@gmail.com) 2017 *
# * Copyright (c) 2017 sliptonic <shopinthewoods@gmail.com> *
# * *
# * This file is part of the FreeCAD CAx development system. *
# * *
@@ -19,7 +19,8 @@
# * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 *
# * USA *
# * *
# ***************************************************************************/
# ***************************************************************************
from __future__ import print_function
import argparse