コード例 #1
0
 def Activated(self):
     selectedDatum = Asm4.getSelectedDatum()
     # check if the datum object is already mapped to something
     if selectedDatum.MapMode == 'Deactivated' and Asm4.checkModel():
         Gui.Control.showDialog(placeDatumUI())
     else:
         Gui.runCommand('Part_EditAttachment')
         '''
コード例 #2
0
    def __init__(self):
        self.base = QtGui.QWidget()
        self.form = self.base
        self.form.setWindowIcon(QtGui.QIcon(iconFile))
        self.form.setWindowTitle('Place a Datum object in the assembly')

        # get the current active document to avoid errors if user changes tab
        self.activeDoc = App.activeDocument()
        # the parent (top-level) assembly is the App::Part called Model (hard-coded)
        self.parentAssembly = self.activeDoc.Model

        # check that we have selected a PartDesign::CoordinateSystem
        self.selectedDatum = Asm4.getSelectedDatum()

        # Now we can draw the UI
        self.drawUI()
        self.initUI()
        # now self.parentList and self.parentTable are available

        # find all the linked parts in the assembly
        for objName in self.parentAssembly.getSubObjects():
            # remove the trailing .
            obj = self.activeDoc.getObject(objName[0:-1])
            if obj.TypeId == 'App::Link':
                # add it to our list if it's a link to an App::Part ...
                if hasattr(obj.LinkedObject, 'isDerivedFrom'):
                    linkedObj = obj.LinkedObject
                    if linkedObj.isDerivedFrom(
                            'App::Part') or linkedObj.isDerivedFrom(
                                'PartDesign::Body'):
                        # add to the object table holding the objects ...
                        self.parentTable.append(obj)
                        # ... and add to the drop-down combo box with the assembly tree's parts
                        objIcon = obj.LinkedObject.ViewObject.Icon
                        objText = Asm4.nameLabel(obj)
                        self.parentList.addItem(objIcon, objText, obj)

        self.old_EE = ' '
        # get and store the Placement's current ExpressionEngine:
        self.old_EE = Asm4.placementEE(self.selectedDatum.ExpressionEngine)

        # decode the old ExpressionEngine
        # if the decode is unsuccessful, old_Expression is set to False
        # and old_attPart and old_attLCS are set to 'None'
        old_Parent = ''
        old_ParentPart = ''
        old_attLCS = ''
        (old_Parent, old_ParentPart,
         old_attLCS) = self.splitExpressionDatum(self.old_EE)

        # find the oldPart in the current part list...
        oldPart = self.parentList.findText(old_Parent)
        # if not found
        if oldPart == -1:
            # set to initial "Select linked Part" entry
            self.parentList.setCurrentIndex(0)
        else:
            self.parentList.setCurrentIndex(oldPart)

        parent_found = False
        parent_index = 1
        for item in self.parentTable[1:]:
            if item.Name == old_Parent:
                parent_found = True
                break
            else:
                parent_index += 1
        if not parent_found:
            parent_index = 0
        self.parentList.setCurrentIndex(parent_index)
        # this should have triggered self.getPartLCS() to fill the LCS list

        # find the old attachment Datum in the list of the Datums in the linked part...
        # lcs_found = []
        lcs_found = self.attLCSlist.findItems(old_attLCS,
                                              QtCore.Qt.MatchExactly)
        if not lcs_found:
            lcs_found = self.attLCSlist.findItems(old_attLCS + ' (',
                                                  QtCore.Qt.MatchContains)
        if lcs_found:
            # ... and select it
            self.attLCSlist.setCurrentItem(lcs_found[0])
コード例 #3
0
 def IsActive(self):
     if App.ActiveDocument and Asm4.getSelectedDatum():
         return True
     return False