コード例 #1
0
    def __init__(self, constraintObject, mode):
        super(a2p_ConstraintValuePanel, self).__init__()
        self.constraintObject = constraintObject
        self.resize(300, 300)
        #
        self.cvw = a2p_ConstraintValueWidget(None, constraintObject, mode)
        self.setWidget(self.cvw)
        self.setWindowTitle("Constraint Properties")
        QtCore.QObject.connect(self.cvw, QtCore.SIGNAL("Accepted()"),
                               self.onAcceptConstraint)
        QtCore.QObject.connect(self.cvw, QtCore.SIGNAL("Deleted()"),
                               self.onDeleteConstraint)

        mw = FreeCADGui.getMainWindow()
        mw.addDockWidget(QtCore.Qt.RightDockWidgetArea, self)

        self.setFloating(True)
        self.activateWindow()
        self.setAllowedAreas(QtCore.Qt.NoDockWidgetArea)
        self.move(getMoveDistToStoredPosition(self))

        a2plib.setConstraintEditorRef(self)
        if mode == 'createConstraint':
            if a2plib.getAutoSolveState():
                doc = FreeCAD.activeDocument()
                if doc != None:
                    solveConstraints(doc)
        self.cvw.activateWindow()
コード例 #2
0
 def solvelist(self, inputList):
     #add 1 at a time then solve allSolve
     workList = []
     doc = FreeCAD.activeDocument()
     for c in inputList:
         workList.append(c)
         print(workList)
         a2p_solversystem.solveConstraints(doc,
                                           matelist=workList,
                                           showFailMessage=False)
コード例 #3
0
    def Activated(self):
        doc = FreeCAD.activeDocument()

        workList = []
        constraints = [
            obj for obj in doc.Objects if 'ConstraintInfo' in obj.Content
        ]

        if len(constraints) == 0:
            flags = QtGui.QMessageBox.StandardButton.Yes
            QtGui.QMessageBox.information(
                QtGui.QApplication.activeWindow(),
                translate("A2plus_searchConstraintConflicts",
                          'Searching for conflicting constraints'),
                translate(
                    "A2plus_searchConstraintConflicts",
                    'There are no a2p constraints within this document.'),
                flags)
            return

        for c in constraints:
            workList.append(c)
            solved = a2p_solversystem.solveConstraints(doc,
                                                       matelist=workList,
                                                       showFailMessage=False)
            if solved == False:
                cMirrorName = c.ViewObject.Proxy.mirror_name
                cmirror = doc.getObject(cMirrorName)
                ob1 = doc.getObject(c.Object1)
                ob2 = doc.getObject(c.Object2)
                message = \
translate("A2plus_searchConstraintConflicts",
                u'''
The following constraint-pair is conflicting
with previously defined constraints:

constraint : {}
with mirror: {}

The constraint-pair belongs to the objects:

object1: {}
object2: {}

Do you want to delete this constraint-pair?
''').format(
                c.Label,
                cmirror.Label,
                ob1.Label,
                ob2.Label
                )
                flags = QtGui.QMessageBox.StandardButton.Yes | QtGui.QMessageBox.StandardButton.No
                response = QtGui.QMessageBox.information(
                    QtGui.QApplication.activeWindow(),
                    translate("A2plus_searchConstraintConflicts",
                              'Searching for conflicting constraints'),
                    message, flags)
                if response == QtGui.QMessageBox.Yes:
                    a2plib.removeConstraint(c)
                return
コード例 #4
0
    def solve(self):
        doc = FreeCAD.activeDocument()
        if self.constraintObject not in doc.Objects:
            QtGui.QMessageBox.information(
                QtGui.QApplication.activeWindow(),
                "Constraint does not exist anymore",
                "Constraint has already been deleted")
            a2plib.setConstraintEditorRef(None)
            self.Deleted.emit()
            return

        self.winModified = True
        self.setConstraintEditorData()
        doc = FreeCAD.activeDocument()
        if doc != None:
            solveConstraints(doc)
            doc.recompute()
コード例 #5
0
 def solvelist(self, list):
     # add 1 at a time then solve allSolve
     workList = []
     solved = 'no run'
     doc = FreeCAD.activeDocument()
     for c in list:
         print(c.Name)
         workList.append(c)
         solved = a2p_solversystem.solveConstraints(doc, None, False, matelist = workList, showFailMessage = False)
     return(solved)
コード例 #6
0
 def stdSolve(self):
     doc = FreeCAD.activeDocument()
     a2p_solversystem.solveConstraints(doc)