def clicked(self, button): if button == QtGui.QDialogButtonBox.Ignore: # ask for confirmation before resetting everything msgName = Asm4.nameLabel(self.selectedLink) # see whether the ExpressionEngine field is filled if self.selectedLink.ExpressionEngine: # if yes, then ask for confirmation confirmed = Asm4.confirmBox( 'This command will release all attachments on ' + msgName + ' and set it to manual positioning in its current location.' ) # if not, then it's useless to bother the user else: confirmed = True if confirmed: # unset the ExpressionEngine for the Placement self.selectedLink.setExpression('Placement', None) # reset the assembly properties Asm4.makeAsmProperties(self.selectedLink, reset=True) # finish FCC.PrintWarning("Part is now manually placed\n") self.finish() else: FCC.PrintWarning("Part untouched\n") self.finish()
def freeInsert(self): # ask for confirmation before resetting everything fName = self.selectedFastener.Name fLabel = self.selectedFastener.Label if fName==fName: fText = fName else: fText = fName+' ('+fName+')' # see whether the ExpressionEngine field is filled if self.old_EE : # if yes, then ask for confirmation confirmed = Asm4.confirmBox('This command will release all attachments on '+fText+' and set it to manual positioning in its current location.') # if not, then it's useless to bother the user else: confirmed = True if confirmed: # unset the ExpressionEngine for the Placement # self.selectedFastener.setExpression( 'Placement', expr ) self.selectedFastener.setExpression('Placement', None) # reset the assembly properties Asm4.makeAsmProperties(self.selectedFastener) # finish self.close() else: return
def freeInsert(self): # ask for confirmation before resetting everything linkName = self.selectedLink.Name linkLabel = self.selectedLink.Label if linkName == linkName: linkText = linkName else: linkText = linkName + ' (' + linkName + ')' # see whether the ExpressionEngine field is filled if self.selectedLink.ExpressionEngine: # if yes, then ask for confirmation confirmed = Asm4.confirmBox( 'This command will release all attachments on ' + linkText + ' and set it to manual positioning in its current location.') # if not, then it's useless to bother the user else: confirmed = True if confirmed: # unset the ExpressionEngine for the Placement self.selectedLink.setExpression('Placement', None) # reset the assembly properties Asm4.makeAsmProperties(self.selectedLink, reset=True) """ # property AssemblyType if hasattr(self.selectedLink,'AssemblyType'): self.selectedLink.AssemblyType = '' else: self.selectedLink.addProperty( 'App::PropertyString', 'AssemblyType', 'Attachment' ).AssemblyType = '' # property AttachedBy if hasattr(self.selectedLink,'AttachedBy'): self.selectedLink.AttachedBy = '' else: self.selectedLink.addProperty( 'App::PropertyString', 'AttachedBy', 'Attachment' ).AttachedBy = '' # property AttachedTo if hasattr(self.selectedLink,'AttachedTo'): self.selectedLink.AttachedTo = '' else: self.selectedLink.addProperty( 'App::PropertyString', 'AttachedTo', 'Attachment' ).AttachedTo = '' # property AttachmentOffset if hasattr(self.selectedLink,'AttachmentOffset'): self.selectedLink.AttachmentOffset = App.Placement() else: self.selectedLink.addProperty( 'App::PropertyPlacement', 'AttachmentOffset', 'Attachment' ).AttachmentOffset = App.Placement() """ Gui.Selection.clearSelection() Gui.Selection.addSelection(self.activeDoc.Name, 'Model', self.selectedLink.Name + '.') # finish self.close() else: return
def clicked(self, bt): if bt == QtGui.QDialogButtonBox.Ignore: # ask for confirmation before resetting everything msgName = Asm4.nameLabel(self.selectedDatum) # see whether the ExpressionEngine field is filled if self.selectedDatum.ExpressionEngine: # if yes, then ask for confirmation confirmed = Asm4.confirmBox( 'This command will release all attachments on ' + msgName + ' and set it to manual positioning in its current location.' ) # if not, then it's useless to bother the user else: confirmed = True if confirmed: self.selectedDatum.setExpression('Placement', None) self.finish()
def clicked(self, bt): if bt == QtGui.QDialogButtonBox.Ignore: # ask for confirmation before resetting everything msgName = Asm4.nameLabel(self.selectedFastener) # see whether the ExpressionEngine field is filled if self.old_EE : # if yes, then ask for confirmation confirmed = Asm4.confirmBox('This command will release all attachments on '+msgName+' and set it to manual positioning in its current location.') else: # if not, then it's useless to bother the user confirmed = True if confirmed: # unset the ExpressionEngine in the Placement self.selectedFastener.setExpression('Placement', None) # reset Asm4 properties Asm4.makeAsmProperties( self.selectedFastener, reset=True ) self.finish()
def Activated(self): # check that we have selected a Fastener from the Fastener WB selection = getSelectionFS() if selection == None: return # check that the fastener is an Asm4 fastener if not hasattr(selection,'AssemblyType'): Asm4.makeAsmProperties(selection) # we only deal with Asm4 or empty types asmType = selection.AssemblyType if asmType=='Asm4EE' or asmType=='': # now we should be safe, call the UI Gui.Control.showDialog( placeFastenerUI() ) else: convert = Asm4.confirmBox("This doesn't seem to be an Assembly4 Fastener") if convert: Asm4.makeAsmProperties( selection, reset=True ) selection.AssemblyType = 'Asm4EE' Gui.Control.showDialog( placeFastenerUI() ) return
def SaveConfiguration(docName, description): print('Saving configuration to "' + docName + '"') doc = GetDocument(docName, 'Configurations') if doc: confirm = Asm4.confirmBox('Override cofiguration in "' + docName + '"?') if not confirm: print('Cancel save...') return else: SetDocumentDescription(doc, description) else: doc = CreateDocument(docName, description, 'Configurations') model = Asm4.getModelSelected() if model: SaveSubObjects(doc, model) else: SaveObject(doc, Asm4.getSelection()) doc.recompute(True)
def SaveConfiguration(self, confName, description): FCC.PrintMessage('Saving configuration to "' + confName + '"\n') conf = getConfig(confName, 'Configurations') if conf: confirm = Asm4.confirmBox('Override configuration in "' + confName + '"?') if not confirm: FCC.PrintMessage('Cancel save...\n') return else: setConfigDescription(conf, description) else: conf = self.createConfig(confName, description, 'Configurations') model = App.ActiveDocument.getObject('Model') link = Asm4.getSelectedLink() if link: self.SaveObject(conf, link) else: self.SaveSubObjects(conf, model) conf.recompute(True)
def Activated(self): # check what we have selected selectedObj = self.checkSelection() if not selectedObj: return objName = selectedObj.Name objLabel = selectedObj.Label objType = selectedObj.TypeId # ask for confirmation before resetting everything if objName==objLabel: objText = objLabel else: objText = objLabel+' ('+objName+')' confirmText = 'This command will release all attachments on '+objText+' and set it to manual positioning in its current location.' """ msgBox = QtGui.QMessageBox() msgBox.setWindowTitle('FreeCAD Warning') msgBox.setIcon(QtGui.QMessageBox.Warning) msgBox.setText('This command will release all attachments on '+objText+' and set it to manual positioning in its current location.') msgBox.setInformativeText('Are you sure you want to proceed ?') msgBox.setStandardButtons(QtGui.QMessageBox.Cancel | QtGui.QMessageBox.Ok) msgBox.setEscapeButton(QtGui.QMessageBox.Cancel) msgBox.setDefaultButton(QtGui.QMessageBox.Ok) retval = msgBox.exec_() # Cancel = 4194304 # Ok = 1024 if retval == 4194304: """ if not Asm4.confirmBox(confirmText): # don't do anything return # the root Assembly4 Model model = App.ActiveDocument.getObject('Model') # handle object types differently # an App::Link if objType == 'App::Link': # unset the ExpressionEngine for the Placement selectedObj.setExpression('Placement', None) # property AssemblyType if hasattr(selectedObj,'AssemblyType'): selectedObj.AssemblyType = '' else: selectedObj.addProperty( 'App::PropertyString', 'AssemblyType', 'Attachment' ).AssemblyType = '' # property AttachedBy if hasattr(selectedObj,'AttachedBy'): selectedObj.AttachedBy = '' else: selectedObj.addProperty( 'App::PropertyString', 'AttachedBy', 'Attachment' ).AttachedBy = '' # property AttachedTo if hasattr(selectedObj,'AttachedTo'): selectedObj.AttachedTo = '' else: selectedObj.addProperty( 'App::PropertyString', 'AttachedTo', 'Attachment' ).AttachedTo = '' # property AttachmentOffset if hasattr(selectedObj,'AttachmentOffset'): selectedObj.AttachmentOffset = App.Placement() else: selectedObj.addProperty( 'App::PropertyPlacement', 'AttachmentOffset', 'Attachment' ).AttachmentOffset = App.Placement() # a datum object elif objType=='PartDesign::CoordinateSystem' or objType=='PartDesign::Plane' or objType=='PartDesign::Line' or objType=='PartDesign::Point' : # unset the MapMode; this actually keeps the MapMode parameters intact, # so it's easy for the user to re-enable it selectedObj.MapMode = 'Deactivated' # unset both Placements (who knows what confusion the user has done) selectedObj.setExpression( 'Placement', None ) selectedObj.setExpression( 'AttachmentOffset', None ) # recompute the assembly model App.ActiveDocument.getObject('Model').recompute(True)
def Activated(self): # 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 = [] selection = self.checkSelectionDatum() if not selection: self.close() else: self.selectedDatum = selection # check if the datum object is already mapped to something if self.selectedDatum.MapMode != 'Deactivated': message = 'This datum object \"'+self.selectedDatum.Label+'\" is mapped to some geometry. Attaching-it with Assembly4 will loose this mapping.' if Asm4.confirmBox(message): # unset MappingMode self.selectedDatum.MapMode = 'Deactivated' else: # don't do anything and ... return # Now we can draw the UI 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') and obj.LinkedObject.isDerivedFrom('App::Part'): self.parentTable.append( obj ) # 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) # get and store the Placement's current ExpressionEngine: self.old_EE = Asm4.placementEE(self.selectedDatum.ExpressionEngine) #self.expression.setText(self.old_EE) # 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 ) = Asm4.splitExpressionDatum( self.old_EE ) self.expression.setText( self.old_EE + ' => old_Parent = '+ old_Parent ) # 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] )