Python Select Mode Script

Python Select Mode Script

Anonymous
Not applicable
1,619 Views
2 Replies
Message 1 of 3

Python Select Mode Script

Anonymous
Not applicable

Hello Everyone,

I'm making a script in python which should wait for the users command, and this command is switching to any component selection from object selection, so essentially, if the script is running, I'd like it to print "great" if I ever switch to Face, Edge or Vertex Selection. Is there any possible way of doing this?

0 Likes
1,620 Views
2 Replies
Replies (2)
Message 2 of 3

rkovach
Enthusiast
Enthusiast

Maya provides some callbacks that let you run code when certain actions occur. one of the more common one is where the selection changes.

 

however, i am not aware of a callback that fires when the component type changes...

 

to get started, look at the "scriptJob" command.

0 Likes
Message 3 of 3

RFlannery1
Collaborator
Collaborator

You might have to use some combination of the events "SelectTypeChanged", "SelectModeChanged", and "SelectPreferenceChanged".  I get different results depending on whether I switch modes using the right-click context menu vs. using the tool buttons at the top of the screen:

  • Right-clicking: Switching to one of the component modes (edge, vertex, face, etc.) fires the event "SelectTypeChanged".  Switching back to object mode fires the event "SelectPreferenceChanged".
  • Tool buttons: Clicking the icon for "Select by Object Type" or "Select by Component Type" fores the "SelectModeChanged" event.  Toggling one of the type buttons, like "point components" or "line components" fires the event "SelectTypeChanged".
0 Likes