Skip to content

Commit

Permalink
Merge pull request #3224 from Russ4262/Fix_rotation_breaks_job
Browse files Browse the repository at this point in the history
[Path] Fix failed Job creation due `EnableRotation` property error
  • Loading branch information
sliptonic committed Mar 22, 2020
2 parents 18054d9 + 9bdbfc2 commit 5fc4a26
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 38 deletions.
5 changes: 5 additions & 0 deletions src/Mod/Path/PathScripts/PathAreaOp.py
Original file line number Diff line number Diff line change
Expand Up @@ -968,3 +968,8 @@ def _customDepthParams(self, obj, strDep, finDep):
final_depth=finDep,
user_depths=None)
return cdp


def SetupProperties():
setup = ['EnableRotation']
return setup
2 changes: 1 addition & 1 deletion src/Mod/Path/PathScripts/PathPocketBase.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ def areaOpPathParams(self, obj, isHole):


def SetupProperties():
setup = []
setup = PathAreaOp.SetupProperties()
setup.append('CutMode')
setup.append('ExtraOffset')
setup.append('StepOver')
Expand Down
64 changes: 32 additions & 32 deletions src/Mod/Path/PathScripts/PathPocketShape.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,14 +62,14 @@ def endPoints(edgeOrWire):
cnt = len([p2 for p2 in pts if PathGeom.pointsCoincide(p, p2)])
if 1 == cnt:
unique.append(p)

return unique

pfirst = edgeOrWire.valueAt(edgeOrWire.FirstParameter)
plast = edgeOrWire.valueAt(edgeOrWire.LastParameter)
if PathGeom.pointsCoincide(pfirst, plast):
return None

return [pfirst, plast]


Expand All @@ -78,7 +78,7 @@ def includesPoint(p, pts):
for pt in pts:
if PathGeom.pointsCoincide(p, pt):
return True

return False


Expand All @@ -89,10 +89,10 @@ def selectOffsetWire(feature, wires):
dist = feature.distToShape(w)[0]
if closest is None or dist > closest[0]: # pylint: disable=unsubscriptable-object
closest = (dist, w)

if closest is not None:
return closest[1]

return None


Expand All @@ -119,7 +119,7 @@ def extendWire(feature, wire, length):
edges.append(Part.Edge(Part.LineSegment(endPts[1], ePts[0])))
edges.extend(offset.Edges)
edges.append(Part.Edge(Part.LineSegment(endPts[0], ePts[1])))

return Part.Wire(edges)
return None

Expand Down Expand Up @@ -154,15 +154,15 @@ def _extendEdge(self, feature, e0, direction):
wire = Part.Wire([e0, e1, e2, e3])
self.wire = wire
return wire

return extendWire(feature, Part.Wire([e0]), self.length.Value)

def _getEdgeNumbers(self):
if 'Wire' in self.sub:
numbers = [nr for nr in self.sub[5:-1].split(',')]
else:
numbers = [self.sub[4:]]

PathLog.debug("_getEdgeNumbers() -> %s" % numbers)
return numbers

Expand All @@ -177,10 +177,10 @@ def _getDirectedNormal(self, p0, normal):
poffMinus = p0 - 0.01 * normal
if not self.obj.Shape.isInside(poffPlus, 0.005, True):
return normal

if not self.obj.Shape.isInside(poffMinus, 0.005, True):
return normal.negative()

return None

def _getDirection(self, wire):
Expand All @@ -191,7 +191,7 @@ def _getDirection(self, wire):
normal = tangent.cross(FreeCAD.Vector(0, 0, 1))
if PathGeom.pointsCoincide(normal, FreeCAD.Vector(0, 0, 0)):
return None

return self._getDirectedNormal(e0.valueAt(midparam), normal.normalize())

def getWire(self):
Expand Down Expand Up @@ -220,7 +220,7 @@ def getWire(self):
r = circle.Radius - self.length.Value
else:
r = circle.Radius + self.length.Value

# assuming the offset produces a valid circle - go for it
if r > 0:
e3 = Part.makeCircle(r, circle.Center, circle.Axis, edge.FirstParameter * 180 / math.pi, edge.LastParameter * 180 / math.pi)
Expand All @@ -229,9 +229,9 @@ def getWire(self):
e0 = Part.makeLine(edge.valueAt(edge.FirstParameter), e3.valueAt(e3.FirstParameter))
e2 = Part.makeLine(edge.valueAt(edge.LastParameter), e3.valueAt(e3.LastParameter))
return Part.Wire([e0, edge, e2, e3])

return Part.Wire([e3])

# the extension is bigger than the hole - so let's just cover the whole hole
if endPoints(edge):
# if the resulting arc is smaller than the radius, create a pie slice
Expand All @@ -240,7 +240,7 @@ def getWire(self):
e0 = Part.makeLine(center, edge.valueAt(edge.FirstParameter))
e2 = Part.makeLine(edge.valueAt(edge.LastParameter), center)
return Part.Wire([e0, edge, e2])

PathLog.track()
return Part.Wire([edge])

Expand All @@ -249,10 +249,10 @@ def getWire(self):
direction = self._getDirection(sub)
if direction is None:
return None

# return self._extendEdge(feature, edge, direction)
return self._extendEdge(feature, edges[0], direction)

return extendWire(feature, sub, self.length.Value)


Expand Down Expand Up @@ -334,7 +334,7 @@ def planarFaceFromExtrusionEdges(face, trans):
PathLog.debug(' -e.isClosed()')
clsd.append(edg)
planar = True

# Attempt to create planar faces and select that with smallest area for use as pocket base
if planar is True:
planar = False
Expand All @@ -348,14 +348,14 @@ def planarFaceFromExtrusionEdges(face, trans):
else:
if trans is True:
mFF.translate(FreeCAD.Vector(0, 0, face.BoundBox.ZMin - mFF.BoundBox.ZMin))

if FreeCAD.ActiveDocument.getObject(fName):
FreeCAD.ActiveDocument.removeObject(fName)

tmpFace = FreeCAD.ActiveDocument.addObject('Part::Feature', fName).Shape = mFF
tmpFace = FreeCAD.ActiveDocument.getObject(fName)
tmpFace.purgeTouched()

if minArea == 0.0:
minArea = tmpFace.Shape.Face1.Area
useFace = fName
Expand All @@ -366,10 +366,10 @@ def planarFaceFromExtrusionEdges(face, trans):
useFace = fName
else:
FreeCAD.ActiveDocument.removeObject(fName)

if useFace != 'useFaceName':
self.useTempJobClones(useFace)

return (planar, useFace)

def clasifySub(self, bs, sub):
Expand All @@ -382,15 +382,15 @@ def clasifySub(self, bs, sub):
# it's a flat horizontal face
self.horiz.append(face)
return True

elif PathGeom.isHorizontal(face.Surface.Axis):
PathLog.debug(' -isHorizontal()')
self.vert.append(face)
return True

else:
return False

elif type(face.Surface) == Part.Cylinder and PathGeom.isVertical(face.Surface.Axis):
PathLog.debug('type() == Part.Cylinder')
# vertical cylinder wall
Expand All @@ -402,13 +402,13 @@ def clasifySub(self, bs, sub):
disk.translate(FreeCAD.Vector(0, 0, face.BoundBox.ZMin - disk.BoundBox.ZMin))
self.horiz.append(disk)
return True

else:
PathLog.debug(' -none isClosed()')
# partial cylinder wall
self.vert.append(face)
return True

elif type(face.Surface) == Part.SurfaceOfExtrusion:
# extrusion wall
PathLog.debug('type() == Part.SurfaceOfExtrusion')
Expand All @@ -427,7 +427,7 @@ def clasifySub(self, bs, sub):
# self.guiMessage(title, msg, False)
else:
PathLog.error(translate("Path", "Failed to create a planar face from edges in {}.".format(sub)))

else:
PathLog.debug(' -type(face.Surface): {}'.format(type(face.Surface)))
return False
Expand All @@ -448,7 +448,7 @@ def clasifySub(self, bs, sub):
# First, check all subs collectively for loop of faces
if len(subsList) > 2:
(isLoop, norm, surf) = self.checkForFacesLoop(base, subsList)

if isLoop is True:
PathLog.info("Common Surface.Axis or normalAt() value found for loop faces.")
rtn = False
Expand Down Expand Up @@ -491,7 +491,7 @@ def clasifySub(self, bs, sub):
stock = PathUtils.findParentJob(obj).Stock
tup = base, subsList, angle, axis, stock
# Eif

allTuples.append(tup)
baseSubsTuples.append(tup)
# Eif
Expand Down
6 changes: 3 additions & 3 deletions src/Mod/Path/PathScripts/PathProfileBase.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ def setOpEditorProperties(self, obj):
def areaOpOnDocumentRestored(self, obj):
for prop in ['UseComp', 'JoinType']:
self.areaOpOnChanged(obj, prop)

self.setOpEditorProperties(obj)

def areaOpAreaParams(self, obj, isHole):
Expand Down Expand Up @@ -135,7 +135,7 @@ def areaOpPathParams(self, obj, isHole):
params['orientation'] = 0
else:
params['orientation'] = 1

if not obj.UseComp:
if direction == 'CCW':
params['orientation'] = 1
Expand All @@ -160,7 +160,7 @@ def areaOpSetDefaultValues(self, obj, job):


def SetupProperties():
setup = []
setup = PathAreaOp.SetupProperties()
setup.append('Side')
setup.append('OffsetExtra')
setup.append('Direction')
Expand Down
3 changes: 1 addition & 2 deletions src/Mod/Path/PathScripts/PathProfileFaces.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,12 +71,11 @@ def initAreaOp(self, obj):

if not hasattr(obj, 'HandleMultipleFeatures'):
obj.addProperty('App::PropertyEnumeration', 'HandleMultipleFeatures', 'Profile', QtCore.QT_TRANSLATE_NOOP('PathPocket', 'Choose how to process multiple Base Geometry features.'))

obj.HandleMultipleFeatures = ['Collectively', 'Individually']

self.initRotationOp(obj)
self.baseObject().initAreaOp(obj)
self.setOpEditorProperties(obj)

def initRotationOp(self, obj):
'''initRotationOp(obj) ... setup receiver for rotation'''
Expand Down

0 comments on commit 5fc4a26

Please sign in to comment.