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.currentIndex() > 0: 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 # constrName has been checked at the beginning ''' if not a_Part : FCC.PrintWarning("Problem in selections (no a_Part)\n") elif not a_LCS : FCC.PrintWarning("Problem in selections (no a_LCS)\n") else: ''' retval = False if a_Part and a_LCS: # don't forget the last '.' !!! # <<LinkName>>.Placement.multiply( <<LinkName>>.<<LCS.>>.Placement ) # expr = '<<'+ a_Part +'>>.Placement.multiply( <<'+ a_Part +'>>.<<'+ a_LCS +'.>>.Placement )' expr = Asm4.makeExpressionDatum(a_Link, a_Part, a_LCS) # load the built expression into the Expression field of the constraint self.activeDoc.getObject(self.selectedDatum.Name).setExpression( 'Placement', expr) # recompute the object to apply the placement: self.selectedDatum.ViewObject.ShowLabel = True self.selectedDatum.ViewObject.FontSize = 20 self.selectedDatum.recompute() # highlight the selected LCS in its new position Gui.Selection.clearSelection() Gui.Selection.addSelection(self.activeDoc.Name, 'Model', self.selectedDatum.Name + '.') retval = True return retval
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.currentIndex() > 0: parent = self.asmParts[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 # constrName has been checked at the beginning if not a_Part or not a_LCS: self.expression.setText('Problem in selections') else: # don't forget the last '.' !!! # <<LinkName>>.Placement.multiply( <<LinkName>>.<<LCS.>>.Placement ) # expr = '<<'+ a_Part +'>>.Placement.multiply( <<'+ a_Part +'>>.<<'+ a_LCS +'.>>.Placement )' expr = Asm4.makeExpressionDatum(a_Link, a_Part, a_LCS) # this can be skipped when this method becomes stable self.expression.setText(expr) # load the built expression into the Expression field of the constraint self.activeDoc.getObject(self.selectedDatum.Name).setExpression( 'Placement', expr) # recompute the object to apply the placement: self.selectedDatum.recompute() # highlight the selected LCS in its new position Gui.Selection.clearSelection() Gui.Selection.addSelection(self.activeDoc.Name, 'Model', self.selectedDatum.Name + '.') return