From c9d6db2173973641d4c3f2e81d29756d95778c04 Mon Sep 17 00:00:00 2001 From: sliptonic Date: Sun, 8 May 2016 15:31:25 -0500 Subject: [PATCH] Profile handles multiple bases now. --- src/Mod/Path/PathScripts/PathProfile.py | 33 ++++++++++++----------- src/Mod/Path/PathScripts/PathSelection.py | 14 ++++------ 2 files changed, 23 insertions(+), 24 deletions(-) diff --git a/src/Mod/Path/PathScripts/PathProfile.py b/src/Mod/Path/PathScripts/PathProfile.py index b9005afce..d933278e9 100644 --- a/src/Mod/Path/PathScripts/PathProfile.py +++ b/src/Mod/Path/PathScripts/PathProfile.py @@ -142,7 +142,7 @@ class ObjectProfile: item = (ss, sub) if item in baselist: - FreeCAD.Console.PrintWarning(translate("Path", "this object already in the list" + "\n")) + FreeCAD.Console.PrintWarning("this object already in the list" + "\n") else: baselist.append(item) obj.Base = baselist @@ -247,7 +247,6 @@ print "y - " + str(point.y) self.horizFeed = 100 self.radius = 0.25 obj.ToolNumber = 0 - FreeCAD.Console.PrintWarning(translate("Path", "No tool found. Using default values for now." + "\n")) else: self.vertFeed = toolLoad.VertFeed.Value self.horizFeed = toolLoad.HorizFeed.Value @@ -256,22 +255,29 @@ print "y - " + str(point.y) obj.ToolNumber = toolLoad.ToolNumber if obj.Base: + hfaces = [] + vfaces = [] + wires = [] + for b in obj.Base: - # we only consider the outer wire if this is a Face - # shape = getattr(obj.Base[0][0].Shape,obj.Base[0][1]) + # Horizontal and vertical faces are handled differently shape = getattr(b[0].Shape, b[1]) + if abs(shape.normalAt(0, 0).z) == 1: # horizontal face + hfaces.append(shape) - if shape.ShapeType in ["Edge"]: - edges = [getattr(obj.Base[0].Shape, sub) for sub in obj.Base[1]] - wire = Part.Wire(edges) + elif abs(shape.normalAt(0, 0).z) == 0: # vertical face + vfaces.append(shape) - if not wire.Edges[0].isSame(shape): - wire.Edges.reverse() + for h in hfaces: + wires.append(h.OuterWire) - else: - wire = shape.OuterWire + tempshell = Part.makeShell(vfaces) + slices = tempshell.slice(FreeCAD.Base.Vector(0, 0, 1), 1.5) + wires = wires + slices + + for wire in wires: edgelist = wire.Edges edgelist = Part.__sortEdges__(edgelist) @@ -445,9 +451,6 @@ class TaskPanel: self.form = FreeCADGui.PySideUic.loadUi(":/panels/ProfileEdit.ui") self.updating = False - def __del__(self): - FreeCADGui.Selection.removeObserver(self.s) - def accept(self): self.getFields() @@ -729,7 +732,7 @@ class SelObserver: PST.clear() def addSelection(self, doc, obj, sub, pnt): - #FreeCADGui.doCommand('Gui.Selection.addSelection(FreeCAD.ActiveDocument.' + obj + ')') + FreeCADGui.doCommand('Gui.Selection.addSelection(FreeCAD.ActiveDocument.' + obj + ')') FreeCADGui.updateGui() diff --git a/src/Mod/Path/PathScripts/PathSelection.py b/src/Mod/Path/PathScripts/PathSelection.py index 6f2b24ce6..2d90582b4 100644 --- a/src/Mod/Path/PathScripts/PathSelection.py +++ b/src/Mod/Path/PathScripts/PathSelection.py @@ -121,31 +121,27 @@ class PROFILEGate: return False if obj.ShapeType == 'Edge': - profileable = True + profileable = False elif obj.ShapeType == 'Compound': - profileable = True if sub[0:4] == 'Face': profileable = True if sub[0:4] == 'Edge': - profileable = True + profileable = False elif obj.ShapeType == 'Face': - profileable = True + profileable = False elif obj.ShapeType == 'Solid': if sub[0:4] == 'Face': profileable = True if sub[0:4] == 'Edge': - profileable = True + profileable = False elif obj.ShapeType == 'Wire': - profileable = True - - if sub[0:6] == 'Vertex': - print "might be fun to try to derive the loop by hovering near a vertex" + profileable = False return profileable