parameters: (name, mode)
docstring: cmdCreateJoinFeature(name, mode): generalized implementation of GUI commands.
docstring_summary: cmdCreateJoinFeature(name, mode): generalized implementation of GUI commands.
docstring_tokens: cmdCreateJoinFeature ( name mode ) : generalized implementation of GUI commands .
function: def cmdCreateJoinFeature(name, mode):
      """cmdCreateJoinFeature(name, mode): generalized implementation of GUI commands."""
      sel = FreeCADGui.Selection.getSelectionEx()
  
      FreeCAD.ActiveDocument.openTransaction("Create "+mode)
      FreeCADGui.addModule("BOPTools.JoinFeatures")
      FreeCADGui.doCommand("j = BOPTools.JoinFeatures.make{mode}(name='{name}')".format(mode=mode, name=name))
      if mode == "Embed" or mode == "Cutout":
          FreeCADGui.doCommand("j.Base = App.ActiveDocument."+sel[0].Object.Name)
          FreeCADGui.doCommand("j.Tool = App.ActiveDocument."+sel[1].Object.Name)
      elif mode == "Connect":
          FreeCADGui.doCommand("j.Objects = {sel}".format(
             sel= "["  +  ", ".join(["App.ActiveDocument."+so.Object.Name for so in sel])  +  "]"
             ))
      else:
          raise ValueError("cmdCreateJoinFeature: Unexpected mode {mode}".format(mode=repr(mode)))
  
      try:
          FreeCADGui.doCommand("j.Proxy.execute(j)")
          FreeCADGui.doCommand("j.purgeTouched()")
      except Exception as err:
          mb = QtGui.QMessageBox()
          mb.setIcon(mb.Icon.Warning)
          mb.setText(_translate("Part_JoinFeatures",
                                "Computing the result failed with an error:\n\n"
                                "{err}\n\n"
                                "Click 'Continue' to create the feature anyway, or 'Abort' to cancel.", None)
                     .format(err=str(err)))
          mb.setWindowTitle(_translate("Part_JoinFeatures","Bad selection", None))
          btnAbort = mb.addButton(QtGui.QMessageBox.StandardButton.Abort)
          btnOK = mb.addButton(_translate("Part_JoinFeatures","Continue",None),
                               QtGui.QMessageBox.ButtonRole.ActionRole)
          mb.setDefaultButton(btnOK)
          mb.exec_()
  
          if mb.clickedButton() is btnAbort:
              FreeCAD.ActiveDocument.abortTransaction()
              return
  
      FreeCADGui.doCommand("for obj in j.ViewObject.Proxy.claimChildren():\n"
                           "    obj.ViewObject.hide()")
  
      FreeCAD.ActiveDocument.commitTransaction()
function_tokens: def cmdCreateJoinFeature ( name , mode ) : sel = FreeCADGui . Selection . getSelectionEx ( ) FreeCAD . ActiveDocument . openTransaction ( "Create " + mode ) FreeCADGui . addModule ( "BOPTools.JoinFeatures" ) FreeCADGui . doCommand ( "j = BOPTools.JoinFeatures.make{mode}(name='{name}')" . format ( mode = mode , name = name ) ) if mode == "Embed" or mode == "Cutout" : FreeCADGui . doCommand ( "j.Base = App.ActiveDocument." + sel [ 0 ] . Object . Name ) FreeCADGui . doCommand ( "j.Tool = App.ActiveDocument." + sel [ 1 ] . Object . Name ) elif mode == "Connect" : FreeCADGui . doCommand ( "j.Objects = {sel}" . format ( sel = "[" + ", " . join ( [ "App.ActiveDocument." + so . Object . Name for so in sel ] ) + "]" ) ) else : raise ValueError ( "cmdCreateJoinFeature: Unexpected mode {mode}" . format ( mode = repr ( mode ) ) ) try : FreeCADGui . doCommand ( "j.Proxy.execute(j)" ) FreeCADGui . doCommand ( "j.purgeTouched()" ) except Exception as err : mb = QtGui . QMessageBox ( ) mb . setIcon ( mb . Icon . Warning ) mb . setText ( _translate ( "Part_JoinFeatures" , "Computing the result failed with an error:\n\n" "{err}\n\n" "Click 'Continue' to create the feature anyway, or 'Abort' to cancel." , None ) . format ( err = str ( err ) ) ) mb . setWindowTitle ( _translate ( "Part_JoinFeatures" , "Bad selection" , None ) ) btnAbort = mb . addButton ( QtGui . QMessageBox . StandardButton . Abort ) btnOK = mb . addButton ( _translate ( "Part_JoinFeatures" , "Continue" , None ) , QtGui . QMessageBox . ButtonRole . ActionRole ) mb . setDefaultButton ( btnOK ) mb . exec_ ( ) if mb . clickedButton ( ) is btnAbort : FreeCAD . ActiveDocument . abortTransaction ( ) return FreeCADGui . doCommand ( "for obj in j.ViewObject.Proxy.claimChildren():\n" "    obj.ViewObject.hide()" ) FreeCAD . ActiveDocument . commitTransaction ( )