Exemplo n.º 1
0
    def getSelectedAxes(self):
        holeAxes = []
        fstnr = None
        selection = Gui.Selection.getSelectionEx('', 0)

        if selection:
            for s in selection:
                for seNames in s.SubElementNames:
                    seObj = s.Object
                    for se in seNames.split('.'):
                        if se and (len(se) > 0):
                            seObj = seObj.getObject(se)
                            if Asm4.isAppLink(seObj):
                                seObj = seObj.getLinkedObject()
                            if Asm4.isHoleAxis(seObj):
                                holeAxes.append(
                                    Asm4.getSelectionPath(
                                        s.Document.Name, s.ObjectName,
                                        seNames))
                                break
                            elif isFastener(seObj):
                                if fstnr is None:
                                    fstnr = seObj
                                    break
                                else:
                                    # only 1 fastener can be selected
                                    return (None)
                        else:
                            break
        # if a fastener and at least 1 HoleAxis have been selected
        if fstnr and (len(holeAxes) > 0):
            return (fstnr, holeAxes)
        else:
            return (None)
Exemplo n.º 2
0
 def addSelection(self, doc, obj, sub, pnt):
     parentFound = False
     # selected object
     selObj = Gui.Selection.getSelection()[0]
     selPath = Asm4.getSelectionPath(doc, obj, sub)
     # check that a datum object is selected
     if selObj.TypeId in Asm4.datumTypes and len(selPath) > 2:
         selLink = self.activeDoc.getObject(selPath[2])
         # if it's the selected link to be placed:
         if selLink == self.selectedObj:
             # try to find the selected LCS in the partLCS list
             found = self.partLCSlist.findItems(Asm4.labelName(selObj), QtCore.Qt.MatchExactly)
             if len(found) > 0:
                 self.partLCSlist.clearSelection()
                 self.partLCSlist.scrollToItem(found[0])
                 self.partLCSlist.setCurrentItem(found[0])
                 # show and highlight LCS
                 selObj.Visibility=True
                 # highlight the entire object if selected in the 3D window
                 if pnt != (0,0,0):
                     pass
                 # preview the part's placement
                 self.Apply()
         # if it's a child in the assembly:
         elif selLink in self.parentTable:
             # find the parent
             idx = self.parentList.findText(Asm4.labelName(selLink), QtCore.Qt.MatchExactly)
             if idx >= 0:
                 self.parentList.setCurrentIndex(idx)
                 # this has triggered to fill in the attachment LCS list
                 parentFound = True
         # if it's the object itself, then it belongs to the root assembly 
         elif selLink == selObj and obj == self.rootAssembly.Name:
             self.parentList.setCurrentIndex(1)
             # this has triggered to fill in the attachment LCS list
             parentFound = True
         # if a parent was found
         if parentFound:
             # now lets try to find the selected LCS in this list
             found = self.attLCSlist.findItems(Asm4.labelName(selObj), QtCore.Qt.MatchExactly)
             if len(found) > 0:
                 self.attLCSlist.clearSelection()
                 self.attLCSlist.scrollToItem(found[0])
                 self.attLCSlist.setCurrentItem(found[0])
                 # show and highlight LCS
                 selObj.Visibility=True
                 # highlight the entire object if selected in the 3D window
                 if pnt != (0,0,0):
                     pass
                 # preview the part's placement
                 self.Apply()
Exemplo n.º 3
0
 def addSelection(self, doc, obj, sub, pnt):
     selPath = Asm4.getSelectionPath(doc, obj, sub)
     selObj = Gui.Selection.getSelection()[0]
     if selObj and len(selPath) > 2:
         selLinkName = selPath[2]
         selLink = App.ActiveDocument.getObject(selLinkName)
         idx = self.parentList.findText(Asm4.labelName(selLink),
                                        QtCore.Qt.MatchExactly)
         # if selLink is in the child list
         if idx >= 0:
             self.parentList.setCurrentIndex(idx)
         # else it might be an LCS in the root assembly
         elif selLink.TypeId in Asm4.datumTypes:
             self.parentList.setCurrentIndex(1)
         # this has triggered to fill the LCS list
         found = self.attLCSlist.findItems(Asm4.labelName(selObj),
                                           QtCore.Qt.MatchExactly)
         if len(found) > 0:
             self.attLCSlist.clearSelection()
             found[0].setSelected(True)
             self.attLCSlist.scrollToItem(found[0])
             self.attLCSlist.setCurrentRow(self.attLCSlist.row(found[0]))
             self.onApply()