Maya Python GUI - Making a picker - how to be able to drag select buttons on a window using maya.cmds?

Maya Python GUI - Making a picker - how to be able to drag select buttons on a window using maya.cmds?

petarpehchevski3d
Explorer Explorer
670 Views
0 Replies
Message 1 of 1

Maya Python GUI - Making a picker - how to be able to drag select buttons on a window using maya.cmds?

petarpehchevski3d
Explorer
Explorer

I'm trying to make a picker. As a test, I currently have 3 cubes in the scene, they represent the arm. I've stored the selection into the button's command, and individually it works. I could even store all 3 in one button selection, but I'd like to be able to drag select all 3 of them at once and make it more intuitive and flexible

I'm aware I could use PySide or QT for this, but I'm trying to keep it to maya.cmds for certain reasons. Basically without having to install additional modules and such to Maya. 

I've attached the code below for anyone interested in taking a look. 

 

import maya.cmds as cmds
import maya.mel as mel
cmds.window("Arm_Control", title="Arm", wh=[288.0, 288.0], s=False)
cmds.formLayout("formLayout", numberOfDivisions=100, w=288.0, h=288.0)

#Creates the cubes and parents them to each other. This is supposed to mimick an arm
cmds.polyCube(n="Shoulder")
cmds.polyCube(n="Elbow")
cmds.polyCube(n="Wrist")

cmds.setAttr("Elbow.ty", -1.5)
cmds.setAttr("Wrist.ty", -3)

cmds.parent("Wrist", "Elbow", )
cmds.parent("Elbow", "Shoulder" )


#We create the buttons and a function that stores the selection sets. Upon pressing the button, we select the cubes.

def Wrist_Button_SS(button):
    exec(str( cmds.select("Wrist")))
button_Wrist_Button_SS = Wrist_Button_SS
cmds.button("Wrist_Button_SS", l="Wrist", ann="", recomputeSize = True, bgc=[0.45400167849240863, 0.45400167849240863, 0.45400167849240863], h = 49.362586349587794, w = 100.0,c=button_Wrist_Button_SS,  parent ="formLayout")
cmds.formLayout("formLayout", edit=True, attachForm=[("Wrist_Button_SS", "top",191.40357806156595), ("Wrist_Button_SS", "left",82.79126994609834)])

def Elbow_Button_SS(button):
    exec(str( cmds.select("Elbow")))
button_Elbow_Button_SS = Elbow_Button_SS
cmds.button("Elbow_Button_SS", l="Elbow", ann="", recomputeSize = True, bgc=[0.45400167849240863, 0.45400167849240863, 0.45400167849240863], h = 49.362586349587794, w = 100.0,c=button_Elbow_Button_SS,  parent ="formLayout")
cmds.formLayout("formLayout", edit=True, attachForm=[("Elbow_Button_SS", "top",119.03931848716638), ("Elbow_Button_SS", "left",81.88357425928116)])

def Shoulder_Button_SS(button):
    exec(str( cmds.select("Shoulder")))
button_Shoulder_Button_SS = Shoulder_Button_SS
cmds.button("Shoulder_Button_SS", l="Shoulder", ann="", recomputeSize = True, bgc=[0.45400167849240863, 0.45400167849240863, 0.45400167849240863], h = 49.362586349587794, w = 100.0,c=button_Shoulder_Button_SS,  parent ="formLayout")
cmds.formLayout("formLayout", edit=True, attachForm=[("Shoulder_Button_SS", "top",44.684211468350256), ("Shoulder_Button_SS", "left",81.88357201371167)])


cmds.showWindow("Arm_Control")

 

I'm aware that this is a longshot. If I can't drag/marquee select on the buttons or have that way to select selection sets, I might make it so that the user can hold shift when clicking the buttons to add onto the selection, but I'd prefer to set it up with a drag selection, sort of like DW picker or Animschool picker. Thank you to whoever can help out with this.

0 Likes
671 Views
0 Replies
Replies (0)