parameters: (self)
docstring: When the workbench is first loaded.
docstring_summary: When the workbench is first loaded.
docstring_tokens: When the workbench is first loaded .
function: def Initialize(self):
          """When the workbench is first loaded."""
  
          def QT_TRANSLATE_NOOP(context, text):
              return text
  
          # Run self-tests
          dependencies_OK = False
          try:
              from pivy import coin
              if FreeCADGui.getSoDBVersion() != coin.SoDB.getVersion():
                  raise AssertionError("FreeCAD and Pivy use different versions "
                                       "of Coin. "
                                       "This will lead to unexpected behaviour.")
          except AssertionError:
              FreeCAD.Console.PrintWarning("Error: FreeCAD and Pivy "
                                           "use different versions of Coin. "
                                           "This will lead to unexpected "
                                           "behaviour.\n")
          except ImportError:
              FreeCAD.Console.PrintWarning("Error: Pivy not found, "
                                           "Draft Workbench will be disabled.\n")
          except Exception:
              FreeCAD.Console.PrintWarning("Error: Unknown error "
                                           "while trying to load Pivy.\n")
          else:
              dependencies_OK = True
  
          if not dependencies_OK:
              return
  
          # Import Draft tools, icons
          try:
              import Draft_rc
              import DraftTools
              import DraftGui
              import DraftFillet
              FreeCADGui.addLanguagePath(":/translations")
              FreeCADGui.addIconPath(":/icons")
          except Exception as exc:
              FreeCAD.Console.PrintError(exc)
              FreeCAD.Console.PrintError("Error: Initializing one or more "
                                         "of the Draft modules failed, "
                                         "Draft will not work as expected.\n")
  
          # Set up command lists
          import draftutils.init_tools as it
          self.drawing_commands = it.get_draft_drawing_commands()
          self.annotation_commands = it.get_draft_annotation_commands()
          self.modification_commands = it.get_draft_modification_commands()
          self.utility_commands_menu = it.get_draft_utility_commands_menu()
          self.utility_commands_toolbar = it.get_draft_utility_commands_toolbar()
          self.context_commands = it.get_draft_context_commands()
  
          # Set up toolbars
          it.init_toolbar(self,
                          QT_TRANSLATE_NOOP("Workbench", "Draft creation tools"),
                          self.drawing_commands)
          it.init_toolbar(self,
                          QT_TRANSLATE_NOOP("Workbench", "Draft annotation tools"),
                          self.annotation_commands)
          it.init_toolbar(self,
                          QT_TRANSLATE_NOOP("Workbench", "Draft modification tools"),
                          self.modification_commands)
          it.init_toolbar(self,
                          QT_TRANSLATE_NOOP("Workbench", "Draft utility tools"),
                          self.utility_commands_toolbar)
  
          # Set up menus
          it.init_menu(self,
                       [QT_TRANSLATE_NOOP("Workbench", "&Drafting")],
                       self.drawing_commands)
          it.init_menu(self,
                       [QT_TRANSLATE_NOOP("Workbench", "&Annotation")],
                       self.annotation_commands)
          it.init_menu(self,
                       [QT_TRANSLATE_NOOP("Workbench", "&Modification")],
                       self.modification_commands)
          it.init_menu(self,
                       [QT_TRANSLATE_NOOP("Workbench", "&Utilities")],
                       self.utility_commands_menu)
  
          # Set up preferences pages
          if hasattr(FreeCADGui, "draftToolBar"):
              if not hasattr(FreeCADGui.draftToolBar, "loadedPreferences"):
                  FreeCADGui.addPreferencePage(":/ui/preferences-draft.ui", QT_TRANSLATE_NOOP("Draft", "Draft"))
                  FreeCADGui.addPreferencePage(":/ui/preferences-draftinterface.ui", QT_TRANSLATE_NOOP("Draft", "Draft"))
                  FreeCADGui.addPreferencePage(":/ui/preferences-draftsnap.ui", QT_TRANSLATE_NOOP("Draft", "Draft"))
                  FreeCADGui.addPreferencePage(":/ui/preferences-draftvisual.ui", QT_TRANSLATE_NOOP("Draft", "Draft"))
                  FreeCADGui.addPreferencePage(":/ui/preferences-drafttexts.ui", QT_TRANSLATE_NOOP("Draft", "Draft"))
                  FreeCADGui.draftToolBar.loadedPreferences = True
  
          FreeCAD.Console.PrintLog('Loading Draft workbench, done.\n')
function_tokens: def Initialize ( self ) : def QT_TRANSLATE_NOOP ( context , text ) : return text # Run self-tests dependencies_OK = False try : from pivy import coin if FreeCADGui . getSoDBVersion ( ) != coin . SoDB . getVersion ( ) : raise AssertionError ( "FreeCAD and Pivy use different versions " "of Coin. " "This will lead to unexpected behaviour." ) except AssertionError : FreeCAD . Console . PrintWarning ( "Error: FreeCAD and Pivy " "use different versions of Coin. " "This will lead to unexpected " "behaviour.\n" ) except ImportError : FreeCAD . Console . PrintWarning ( "Error: Pivy not found, " "Draft Workbench will be disabled.\n" ) except Exception : FreeCAD . Console . PrintWarning ( "Error: Unknown error " "while trying to load Pivy.\n" ) else : dependencies_OK = True if not dependencies_OK : return # Import Draft tools, icons try : import Draft_rc import DraftTools import DraftGui import DraftFillet FreeCADGui . addLanguagePath ( ":/translations" ) FreeCADGui . addIconPath ( ":/icons" ) except Exception as exc : FreeCAD . Console . PrintError ( exc ) FreeCAD . Console . PrintError ( "Error: Initializing one or more " "of the Draft modules failed, " "Draft will not work as expected.\n" ) # Set up command lists import draftutils . init_tools as it self . drawing_commands = it . get_draft_drawing_commands ( ) self . annotation_commands = it . get_draft_annotation_commands ( ) self . modification_commands = it . get_draft_modification_commands ( ) self . utility_commands_menu = it . get_draft_utility_commands_menu ( ) self . utility_commands_toolbar = it . get_draft_utility_commands_toolbar ( ) self . context_commands = it . get_draft_context_commands ( ) # Set up toolbars it . init_toolbar ( self , QT_TRANSLATE_NOOP ( "Workbench" , "Draft creation tools" ) , self . drawing_commands ) it . init_toolbar ( self , QT_TRANSLATE_NOOP ( "Workbench" , "Draft annotation tools" ) , self . annotation_commands ) it . init_toolbar ( self , QT_TRANSLATE_NOOP ( "Workbench" , "Draft modification tools" ) , self . modification_commands ) it . init_toolbar ( self , QT_TRANSLATE_NOOP ( "Workbench" , "Draft utility tools" ) , self . utility_commands_toolbar ) # Set up menus it . init_menu ( self , [ QT_TRANSLATE_NOOP ( "Workbench" , "&Drafting" ) ] , self . drawing_commands ) it . init_menu ( self , [ QT_TRANSLATE_NOOP ( "Workbench" , "&Annotation" ) ] , self . annotation_commands ) it . init_menu ( self , [ QT_TRANSLATE_NOOP ( "Workbench" , "&Modification" ) ] , self . modification_commands ) it . init_menu ( self , [ QT_TRANSLATE_NOOP ( "Workbench" , "&Utilities" ) ] , self . utility_commands_menu ) # Set up preferences pages if hasattr ( FreeCADGui , "draftToolBar" ) : if not hasattr ( FreeCADGui . draftToolBar , "loadedPreferences" ) : FreeCADGui . addPreferencePage ( ":/ui/preferences-draft.ui" , QT_TRANSLATE_NOOP ( "Draft" , "Draft" ) ) FreeCADGui . addPreferencePage ( ":/ui/preferences-draftinterface.ui" , QT_TRANSLATE_NOOP ( "Draft" , "Draft" ) ) FreeCADGui . addPreferencePage ( ":/ui/preferences-draftsnap.ui" , QT_TRANSLATE_NOOP ( "Draft" , "Draft" ) ) FreeCADGui . addPreferencePage ( ":/ui/preferences-draftvisual.ui" , QT_TRANSLATE_NOOP ( "Draft" , "Draft" ) ) FreeCADGui . addPreferencePage ( ":/ui/preferences-drafttexts.ui" , QT_TRANSLATE_NOOP ( "Draft" , "Draft" ) ) FreeCADGui . draftToolBar . loadedPreferences = True FreeCAD . Console . PrintLog ( 'Loading Draft workbench, done.\n' )