Ejemplo n.º 1
0
    def Activated(self):
        from PathScripts.PathUtils import horizontalEdgeLoop
        from PathScripts.PathUtils import horizontalFaceLoop
        sel = FreeCADGui.Selection.getSelectionEx()[0]
        obj = sel.Object
        edge1 = sel.SubObjects[0]
        if 'Face' in sel.SubElementNames[0]:
            loop = horizontalFaceLoop(sel.Object, sel.SubObjects[0], sel.SubElementNames)
            if loop:
                FreeCADGui.Selection.clearSelection()
                FreeCADGui.Selection.addSelection(sel.Object, loop)
            loopwire = []
        elif len(sel.SubObjects) == 1:
            loopwire = horizontalEdgeLoop(obj, edge1)
        else:
            edge2 = sel.SubObjects[1]
            loopwire = loopdetect(obj, edge1, edge2)

        if loopwire:
            FreeCADGui.Selection.clearSelection()
            elist = obj.Shape.Edges
            for e in elist:
                for i in loopwire.Edges:
                    if e.hashCode() == i.hashCode():
                        FreeCADGui.Selection.addSelection(obj, "Edge" + str(elist.index(e) + 1))
        elif FreeCAD.GuiUp:
            QtGui.QMessageBox.information(None,
                    QtCore.QT_TRANSLATE_NOOP('Path_SelectLoop', 'Feature Completion'),
                    QtCore.QT_TRANSLATE_NOOP('Path_SelectLoop', 'Closed loop detection failed.'))
Ejemplo n.º 2
0
    def Activated(self):
        sel = FreeCADGui.Selection.getSelectionEx()[0]
        obj = sel.Object
        edge1 = sel.SubObjects[0]
        if 'Face' in sel.SubElementNames[0]:
            loop = horizontalFaceLoop(sel.Object, sel.SubObjects[0],
                                      sel.SubElementNames)
            if loop:
                FreeCADGui.Selection.clearSelection()
                FreeCADGui.Selection.addSelection(sel.Object, loop)
            loopwire = []
        elif len(sel.SubObjects) == 1:
            loopwire = horizontalEdgeLoop(obj, edge1)
        else:
            edge2 = sel.SubObjects[1]
            loopwire = loopdetect(obj, edge1, edge2)

        if loopwire:
            FreeCADGui.Selection.clearSelection()
            elist = obj.Shape.Edges
            for e in elist:
                for i in loopwire.Edges:
                    if e.hashCode() == i.hashCode():
                        FreeCADGui.Selection.addSelection(
                            obj, "Edge" + str(elist.index(e) + 1))
Ejemplo n.º 3
0
    def Activated(self):
        from PathScripts.PathUtils import loopdetect
        from PathScripts.PathUtils import horizontalEdgeLoop
        from PathScripts.PathUtils import horizontalFaceLoop
        sel = FreeCADGui.Selection.getSelectionEx()[0]
        obj = sel.Object
        edge1 = sel.SubObjects[0]
        if 'Face' in sel.SubElementNames[0]:
            loop = horizontalFaceLoop(sel.Object, sel.SubObjects[0], sel.SubElementNames)
            if loop:
                FreeCADGui.Selection.clearSelection()
                FreeCADGui.Selection.addSelection(sel.Object, loop)
            loopwire = []
        elif len(sel.SubObjects) == 1:
            loopwire = horizontalEdgeLoop(obj, edge1)
        else:
            edge2 = sel.SubObjects[1]
            loopwire = loopdetect(obj, edge1, edge2)

        if loopwire:
            FreeCADGui.Selection.clearSelection()
            elist = obj.Shape.Edges
            for e in elist:
                for i in loopwire.Edges:
                    if e.hashCode() == i.hashCode():
                        FreeCADGui.Selection.addSelection(obj, "Edge"+str(elist.index(e)+1))
Ejemplo n.º 4
0
 def formsPartOfALoop(self, obj, sub, names):
     if names[0][0:4] != 'Edge':
         if names[0][0:4] == 'Face' and horizontalFaceLoop(obj, sub, names):
             return True
         return False
     if len(names) == 1 and horizontalEdgeLoop(obj, sub):
         return True
     if len(names) == 1 or names[1][0:4] != 'Edge':
         return False
     return True
Ejemplo n.º 5
0
 def formsPartOfALoop(self, obj, sub, names):
     if names[0][0:4] != 'Edge':
         if names[0][0:4] == 'Face' and horizontalFaceLoop(obj, sub, names):
             return True
         return False
     if len(names) == 1 and horizontalEdgeLoop(obj, sub):
         return True
     if len(names) == 1 or names[1][0:4] != 'Edge':
         return False
     return True
Ejemplo n.º 6
0
 def formsPartOfALoop(self, obj, sub, names):
     try:
         if names[0][0:4] != "Edge":
             if names[0][0:4] == "Face" and horizontalFaceLoop(
                     obj, sub, names):
                 return True
             return False
         if len(names) == 1 and horizontalEdgeLoop(obj, sub):
             return True
         if len(names) == 1 or names[1][0:4] != "Edge":
             return False
         return True
     except Exception:
         return False
Ejemplo n.º 7
0
 def IsActive(self):
     if bool(FreeCADGui.Selection.getSelection()) is False:
         return False
     try:
         sel = FreeCADGui.Selection.getSelectionEx()[0]
         sub1 = sel.SubElementNames[0]
         if sub1[0:4] != 'Edge':
             if sub1[0:4] == 'Face' and horizontalFaceLoop(
                     sel.Object, sel.SubObjects[0], sel.SubElementNames):
                 return True
             return False
         if len(sel.SubElementNames) == 1 and horizontalEdgeLoop(
                 sel.Object, sel.SubObjects[0]):
             return True
         sub2 = sel.SubElementNames[1]
         if sub2[0:4] != 'Edge':
             return False
         return True
     except:
         return False