Path: Improvements to user messages

Remove some messages.
Implement FreeCAD.Console.Print___() in place of PathLog.___().
Path: fixes
This commit is contained in:
Russell Johnson
2020-04-28 12:59:02 -05:00
parent d4fafcc34c
commit a9ee9af710

View File

@@ -90,7 +90,7 @@ class PathGeometryGenerator:
if shape.BoundBox.ZLength == 0.0:
self.shape = shape
else:
PathLog.warning('Shape appears to not be horizontal planar. ZMax is {}.'.format(shape.BoundBox.ZMax))
FreeCAD.Console.PrintWarning('Shape appears to not be horizontal planar. ZMax is {}.\n'.format(shape.BoundBox.ZMax))
self._prepareConstants()
@@ -114,7 +114,8 @@ class PathGeometryGenerator:
fCnt += 1
zeroCOM = zeroCOM.add(FreeCAD.Vector(comF.x, comF.y, 0.0).multiply(areaF))
if fCnt == 0:
PathLog.error(translate(self.module, 'Cannot calculate the Center Of Mass. Using Center of Boundbox instead.'))
msg = translate(self.module, 'Cannot calculate the Center Of Mass. Using Center of Boundbox instead.')
FreeCAD.Console.PrintError(msg + '\n')
bbC = self.shape.BoundBox.Center
zeroCOM = FreeCAD.Vector(bbC.x, bbC.y, 0.0)
else:
@@ -151,11 +152,11 @@ class PathGeometryGenerator:
'''generatePathGeometry()...
Call this function to obtain the path geometry shape, generated by this class.'''
if self.pattern == 'None':
PathLog.warning('PGG: No pattern set.')
# FreeCAD.Console.PrintWarning('PGG: No pattern set.\n')
return False
if self.shape is None:
PathLog.warning('PGG: No shape set.')
# FreeCAD.Console.PrintWarning('PGG: No shape set.\n')
return False
cmd = 'self._' + self.pattern + '()'
@@ -403,7 +404,7 @@ class PathGeometryGenerator:
while cont:
ofstArea = self._getFaceOffset(shape, ofst)
if not ofstArea:
PathLog.warning('PGG: No offset clearing area returned.')
# FreeCAD.Console.PrintWarning('PGG: No offset clearing area returned.\n')
cont = False
break
for F in ofstArea.Faces:
@@ -469,7 +470,7 @@ class ProcessSelectedFaces:
self.module = None
self.radius = None
self.depthParams = None
self.msgNoFaces = translate(self.module, 'Face selection is unavailable for Rotational scans. Ignoring selected faces.')
self.msgNoFaces = translate(self.module, 'Face selection is unavailable for Rotational scans. Ignoring selected faces.') + '\n'
self.JOB = JOB
self.obj = obj
self.profileEdges = 'None'
@@ -492,7 +493,7 @@ class ProcessSelectedFaces:
self.checkBase = True
if self.obj.ScanType == 'Rotational':
self.checkBase = False
PathLog.warning(self.msgNoFaces)
FreeCAD.Console.PrintWarning(self.msgNoFaces)
def PathWaterline(self):
if self.obj.Base:
@@ -500,7 +501,7 @@ class ProcessSelectedFaces:
self.checkBase = True
if self.obj.Algorithm in ['OCL Dropcutter', 'Experimental']:
self.checkBase = False
PathLog.warning(self.msgNoFaces)
FreeCAD.Console.PrintWarning(self.msgNoFaces)
# public class methods
def setShowDebugObjects(self, grpObj, val):
@@ -563,7 +564,7 @@ class ProcessSelectedFaces:
pPEB = self._preProcessEntireBase(base, m)
if pPEB is False:
PathLog.error(' -Failed to pre-process base as a whole.')
FreeCAD.Console.PrintError(' -Failed to pre-process base as a whole.\n')
else:
(fcShp, prflShp) = pPEB
if fcShp is not False:
@@ -672,7 +673,8 @@ class ProcessSelectedFaces:
PathLog.debug('Attempting to get cross-section of collective faces.')
if len(outFCS) == 0:
# FreeCAD.Console.PrintError(translate('PathSurfaceSupport', 'Cannot process selected faces. Check horizontal surface exposure.\n'))
msg = translate('PathSurfaceSupport', 'Cannot process selected faces. Check horizontal surface exposure.')
FreeCAD.Console.PrintError(msg + '\n')
cont = False
else:
cfsL = Part.makeCompound(outFCS)
@@ -687,7 +689,7 @@ class ProcessSelectedFaces:
mFS = True
cont = False
else:
PathLog.error(' -Failed to create profile geometry for selected faces.')
# FreeCAD.Console.PrintError(' -Failed to create profile geometry for selected faces.\n')
cont = False
if cont:
@@ -700,7 +702,7 @@ class ProcessSelectedFaces:
ofstVal = self._calculateOffsetValue(isHole)
faceOfstShp = extractFaceOffset(cfsL, ofstVal, self.wpc)
if faceOfstShp is False:
PathLog.error(' -Failed to create offset face.')
FreeCAD.Console.PrintError(' -Failed to create offset face.\n')
cont = False
if cont:
@@ -834,7 +836,7 @@ class ProcessSelectedFaces:
ofstVal = self._calculateOffsetValue(isHole, isVoid=True)
avdOfstShp = extractFaceOffset(avoid, ofstVal, self.wpc)
if avdOfstShp is False:
PathLog.error('Failed to create collective offset avoid face.')
FreeCAD.Console.PrintError('Failed to create collective offset avoid face.\n')
cont = False
if cont:
@@ -848,7 +850,7 @@ class ProcessSelectedFaces:
ofstVal = self._calculateOffsetValue(isHole=True)
ifOfstShp = extractFaceOffset(ifc, ofstVal, self.wpc)
if ifOfstShp is False:
PathLog.error('Failed to create collective offset avoid internal features.')
FreeCAD.Console.PrintError('Failed to create collective offset avoid internal features.\n')
else:
avdShp = avdOfstShp.cut(ifOfstShp)
@@ -896,14 +898,14 @@ class ProcessSelectedFaces:
return (True, psOfst)
prflShp = psOfst
else:
PathLog.error(' -Failed to create profile geometry.')
# FreeCAD.Console.PrintError(' -Failed to create profile geometry.\n')
cont = False
if cont:
ofstVal = self._calculateOffsetValue(isHole)
faceOffsetShape = extractFaceOffset(csFaceShape, ofstVal, self.wpc)
if faceOffsetShape is False:
PathLog.error('extractFaceOffset() failed.')
PathLog.error('extractFaceOffset() failed for entire base.')
else:
faceOffsetShape.translate(FreeCAD.Vector(0.0, 0.0, 0.0 - faceOffsetShape.BoundBox.ZMin))
return (faceOffsetShape, prflShp)
@@ -1058,7 +1060,7 @@ def getShapeEnvelope(shape):
try:
env = PathUtils.getEnvelope(partshape=shape, depthparams=dep_par) # Produces .Shape
except Exception as ee:
PathLog.error('try: PathUtils.getEnvelope() failed.\n' + str(ee))
FreeCAD.Console.PrintError('try: PathUtils.getEnvelope() failed.\n' + str(ee) + '\n')
return False
else:
return env
@@ -1768,7 +1770,6 @@ class FindUnifiedRegions:
lenDATA = len(DATA)
indexes = [i for i in range(0, lenDATA)]
idxCnt = len(indexes)
# FreeCAD.Console.PrintWarning('indexes:\n{}\n'.format(indexes))
while idxCnt > 0:
processLast = True
@@ -2000,7 +2001,6 @@ class FindUnifiedRegions:
for i in range(0, len(self.REGIONS)):
Ids.append(i)
idsCnt = len(Ids)
# FreeCAD.Console.PrintWarning('_processNestedRegions() Ids: {}\n'.format(Ids))
while cont:
while idsCnt > 0:
@@ -2157,6 +2157,6 @@ class FindUnifiedRegions:
after calling getUnifiedRegions().'''
if self.INTERNALS:
return self.INTERNALS
FreeCAD.Console.PrintError('getUnifiedRegions() must be called before getInternalFeatures().')
FreeCAD.Console.PrintError('getUnifiedRegions() must be called before getInternalFeatures().\n')
return False
# Eclass