If you need to do any processing before a mode begins to collect input from the user, you can redefine the activate method. For example, you can check that the current viewport contains a part before beginning a mode that requires the user to pick something on a part, as shown in the following method: def activate(self): if getDisplayedObjectType() == PART: AFXForm.activate(self) else: showAFXErrorDialog(getAFXApp().getAFXMainWindow(), 'A part must be displayed in the \ current viewport.') If you write your own activate (or deactivate) method, you must call the base class version of that method if no error conditions are encountered. The base class methods perform additional processing necessary to make the mode function properly. |