Skip to content

Commit

Permalink
Path: Clean up messaging and add translation() usage
Browse files Browse the repository at this point in the history
  • Loading branch information
Russ4262 committed Jun 3, 2020
1 parent 6e36eee commit e1b7fb3
Show file tree
Hide file tree
Showing 2 changed files with 65 additions and 52 deletions.
31 changes: 18 additions & 13 deletions src/Mod/Path/PathScripts/PathSurface.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@
try:
import ocl
except ImportError:
msg = QtCore.QCoreApplication.translate("PathSurface", "This operation requires OpenCamLib to be installed.")
msg = QtCore.QCoreApplication.translate("PathSurface",
"This operation requires OpenCamLib to be installed.")
FreeCAD.Console.PrintError(msg + "\n")
raise ImportError
# import sys
Expand Down Expand Up @@ -575,18 +576,18 @@ def opExecute(self, obj):
PathSurfaceSupport._prepareModelSTLs(self, JOB, obj, m, ocl)

Mdl = JOB.Model.Group[m]
if FACES[m] is False:
PathLog.error('No data for model base: {}'.format(JOB.Model.Group[m].Label))
else:
if FACES[m]:
PathLog.debug('Working on Model.Group[{}]: {}'.format(m, Mdl.Label))
if m > 0:
# Raise to clearance between models
CMDS.append(Path.Command('N (Transition to base: {}.)'.format(Mdl.Label)))
CMDS.append(Path.Command('G0', {'Z': obj.ClearanceHeight.Value, 'F': self.vertRapid}))
PathLog.info('Working on Model.Group[{}]: {}'.format(m, Mdl.Label))
# make stock-model-voidShapes STL model for avoidance detection on transitions
PathSurfaceSupport._makeSafeSTL(self, JOB, obj, m, FACES[m], VOIDS[m], ocl)
# Process model/faces - OCL objects must be ready
CMDS.extend(self._processCutAreas(JOB, obj, m, FACES[m], VOIDS[m]))
else:
PathLog.debug('No data for model base: {}'.format(JOB.Model.Group[m].Label))

# Save gcode produced
self.commandlist.extend(CMDS)
Expand Down Expand Up @@ -659,7 +660,8 @@ def opExecute(self, obj):
exTime = str(tMins) + ' min. ' + str(round(tSecs, 5)) + ' sec.'
else:
exTime = str(round(execTime, 5)) + ' sec.'
FreeCAD.Console.PrintMessage('3D Surface operation time is {}\n'.format(exTime))
msg = translate('PathSurface', 'operation time is')
FreeCAD.Console.PrintMessage('3D Surface ' + msg + '{}\n'.format(exTime))

if self.cancelOperation:
FreeCAD.ActiveDocument.openTransaction(translate("PathSurface", "Canceled 3D Surface operation."))
Expand Down Expand Up @@ -751,13 +753,15 @@ def getTransition(two):
if obj.ProfileEdges != 'None':
prflShp = self.profileShapes[mdlIdx][fsi]
if prflShp is False:
PathLog.error('No profile shape is False.')
msg = translate('PathSurface', 'No profile geometry shape returned.')
PathLog.error(msg)
return list()
self.showDebugObject(prflShp, 'NewProfileShape')
# get offset path geometry and perform OCL scan with that geometry
pathOffsetGeom = self._offsetFacesToPointData(obj, prflShp)
if pathOffsetGeom is False:
PathLog.error('No profile geometry returned.')
msg = translate('PathSurface', 'No profile path geometry returned.')
PathLog.error(msg)
return list()
profScan = [self._planarPerformOclScan(obj, pdc, pathOffsetGeom, True)]

Expand All @@ -771,12 +775,14 @@ def getTransition(two):
self.tmpCOM = PGG.getCenterOfPattern()
pathGeom = PGG.generatePathGeometry()
if pathGeom is False:
PathLog.error('No path geometry returned.')
msg = translate('PathSurface', 'No clearing shape returned.')
PathLog.error(msg)
return list()
if obj.CutPattern == 'Offset':
useGeom = self._offsetFacesToPointData(obj, pathGeom, profile=False)
if useGeom is False:
PathLog.error('No profile geometry returned.')
msg = translate('PathSurface', 'No clearing path geometry returned.')
PathLog.error(msg)
return list()
geoScan = [self._planarPerformOclScan(obj, pdc, useGeom, True)]
else:
Expand All @@ -795,7 +801,8 @@ def getTransition(two):
SCANDATA.extend(profScan)

if len(SCANDATA) == 0:
PathLog.error('No scan data to convert to Gcode.')
msg = translate('PathSuface', 'No scan data to convert to Gcode.')
PathLog.error(msg)
return list()

# Apply depth offset
Expand Down Expand Up @@ -1165,7 +1172,6 @@ def _planarDropCutMulti(self, JOB, obj, pdc, safePDC, depthparams, SCANDATA):

# Manage step over transition and CircularZigZag direction
if so > 0:
# PathLog.debug(' stepover index: {}'.format(so))
# Control ZigZag direction
if obj.CutPattern == 'CircularZigZag':
if odd is True:
Expand All @@ -1187,7 +1193,6 @@ def _planarDropCutMulti(self, JOB, obj, pdc, safePDC, depthparams, SCANDATA):
for i in range(0, lenAdjPrts):
prt = ADJPRTS[i]
lenPrt = len(prt)
# PathLog.debug(' adj parts index - lenPrt: {} - {}'.format(i, lenPrt))
if prt == 'BRK' and prtsHasCmds is True:
nxtStart = ADJPRTS[i + 1][0]
minSTH = self._getMinSafeTravelHeight(safePDC, last, nxtStart, minDep=None) # Check safe travel height against fullSTL
Expand Down

0 comments on commit e1b7fb3

Please sign in to comment.