Пример #1
0
    def Activated(self):
        (fstnr, axes) = self.selection
        if fstnr.Document:
            for axisData in axes:
                if len(axisData) > 3:  # DocName/ModelName/AppLinkName/AxisName
                    docName = axisData[0]
                    doc = App.getDocument(docName)
                    if doc:
                        model = doc.getObject(axisData[1])
                        if model:
                            objLink = model.getObject(axisData[2])
                            if objLink:
                                obj = objLink.getLinkedObject()
                                axis = obj.getObject(axisData[3])
                                if axis and axis.Document:
                                    newFstnr = Asm4.cloneObject(fstnr)
                                    Asm4.placeObjectToLCS(
                                        newFstnr, axisData[2],
                                        axis.Document.Name, axisData[3])

            Gui.Selection.clearSelection()
            self.rootAssembly = Asm4.getAssembly()
            if rootAssembly:
                Gui.Selection.addSelection(fstnr.Document.Name,
                                           self.rootAssembly.Name,
                                           fstnr.Name + '.')
Пример #2
0
    def onApply(self):
        # get the name of the part to attach to:
        # it's either the top level part name ('Model')
        # or the provided link's name.
        if self.parentList.currentText() == 'Parent Assembly':
            a_Link = 'Parent Assembly'
            a_Part = None
        elif self.parentList.currentIndex() > 1:
            parent = self.parentTable[self.parentList.currentIndex()]
            a_Link = parent.Name
            a_Part = parent.LinkedObject.Document.Name
        else:
            a_Link = None
            a_Part = None

        # the attachment LCS's name in the parent
        # check that something is selected in the QlistWidget
        if self.attLCSlist.selectedItems():
            a_LCS = self.attLCStable[self.attLCSlist.currentRow()].Name
        else:
            a_LCS = None

        # check that all of them have something in
        if a_Link and a_LCS:
            # add Asm4 properties if necessary
            Asm4.makeAsmProperties(self.selectedFastener, reset=True)
            # hide "offset" and "invert" properties to avoid confusion as they are not used in Asm4
            if hasattr(self.selectedFastener, 'offset'):
                self.selectedFastener.setPropertyStatus('offset', 'Hidden')
            if hasattr(self.selectedFastener, 'invert'):
                self.selectedFastener.setPropertyStatus('invert', 'Hidden')

            # <<LinkName>>.Placement.multiply( <<LinkName>>.<<LCS.>>.Placement )
            # expr = '<<'+ a_Part +'>>.Placement.multiply( <<'+ a_Part +'>>.<<'+ a_LCS +'.>>.Placement )'

            Asm4.placeObjectToLCS(self.selectedFastener, a_Link, a_Part, a_LCS)

            # highlight the selected fastener in its new position
            Gui.Selection.clearSelection()
            Gui.Selection.addSelection(self.activeDoc.Name,
                                       self.rootAssembly.Name,
                                       self.selectedFastener.Name + '.')
        else:
            FCC.PrintWarning("Problem in selections\n")
        return