Home Technical Talk

Maya Scirpting (python)

passerby
polycounter lvl 12
Offline / Send Message
passerby polycounter lvl 12
been working on building the gui for a script i made for maya, and am having some issues with the change command of the "cmds.radioButtonGrp()" method, with it firing the change command twice every-time a new radio button is selected.

this is how im calling it.
cmds.radioButtonGrp( 'dupType', label='Duplicate Type', labelArray2=['Dupilcate', 'Instance'], numberOfRadioButtons=2, sl=1, cc=lambda z:createCurve() )

and i got other gui elemeants that use the change command fine and only fire it once as expected for each change to the feild.

Replies

  • St.Sabath
    Options
    Offline / Send Message
    St.Sabath polycounter lvl 11
    not that it will solve your problem,but is that a typo in your line there? lol
    labelArray2=['Dupilcate', 'Instance']
  • passerby
    Options
    Offline / Send Message
    passerby polycounter lvl 12
    ya i found that type since, which actually is just visual and has no effect on the code anyways, still trying to figure out why it is being called twice with the change command(cc) on the radioButtonGrp, but not when used on other UI elements such as the intSliderGrp, which i am also using with the same change command.
  • haiddasalami
    Options
    Offline / Send Message
    haiddasalami polycounter lvl 14
    Dont have Maya to test but I think the script is running it twice for both on and off. Could test in the function and see if the button is on and off or use onCommand and offCommand.
  • Jedi
    Options
    Offline / Send Message
    Jedi polycounter lvl 12
    You should write all your GUIs in pyqt - especially since autodesk switched the entire interface to qt. Its much much much easier to write and soooo quick. Have a look at this page for a checkbox change state example.

    http://zetcode.com/tutorials/pyqt4/widgets/
    example
    cb = QtGui.QCheckBox('Show title', self)
    
    cb.stateChanged.connect(self.changeTitle)
    
            
    def changeTitle(self, state):
        if state == QtCore.Qt.Checked:
            self.setWindowTitle('QtGui.QCheckBox')
        else:
            self.setWindowTitle('')
    
  • passerby
    Options
    Offline / Send Message
    passerby polycounter lvl 12
    ya found part of the issue, when it runs it is running with the initial option, than again with the change, and if i remove the sl=1 so it starts off empty with no selection, it will only run once, so i will have to look into something besides cc aka changecommand for it.

    @Jedi never really saw much point, since the gui literally has only 4 elements, and i dont need anything beyond the features already there in maya.cmds.

    EDIT: Thanks again haiddasalami, using the oncommand(onc) made it work as wanted.

    EDIT2: now a more complex question, is there a way to iterate through the render triangles with out having to first triangulate the mesh?
  • passerby
    Options
    Offline / Send Message
    passerby polycounter lvl 12
    is there anyway in python to iterate with 2 arguments with a for in loop.

    such as doing something like
    for gObj in Duplicates:
    
    and something like
    for count in range( len(Duplicates) ):
    
    in the same for loop.

    i got a case where i need to iterate through a list of objects, but also need to keep a count for some math that happens later on in the loop.

    or even better just use the original loop arugmeant, but figure out which iteration of the loop the script is currently in.
  • haiddasalami
    Options
    Offline / Send Message
    haiddasalami polycounter lvl 14
    why not do something like:
    x = [4,5,6]
    counter = 0
    
    for i in range(len(x)):
          counter += 1 
          print x[i]
    

    That works more like a classic for loop (for int i = 0; i < length(x); i++) etc. Maybe Im not reading this right but let me know.
  • passerby
    Options
    Offline / Send Message
    passerby polycounter lvl 12
    ya i just already did what you did in declaring the count = 0 out of the loop than incrementing it at the end of the loop.

    little tired tonight
  • haiddasalami
    Options
    Offline / Send Message
    haiddasalami polycounter lvl 14
    passerby wrote: »
    ya i just already did what you did in declaring the count = 0 out of the loop than incrementing it at the end of the loop.

    little tired tonight

    haha drank a bunch of beers and on a shaky VIA train isnt fun :) so just wanted to make sure. Awesome you got it working!
  • passerby
    Options
    Offline / Send Message
    passerby polycounter lvl 12
    ya working on kinda a maya version of something like Miauu's "Clone between" tool with a few added features almost there expect for a spacing issue between the original geometry and the instances made by the tool.
Sign In or Register to comment.