Chit Chat

Rigging101 » Chit Chat12

Stupid Python tricks (8 posts)

About This Topic

Tags

No tags yet.

  1. Smapdi

    offline
    Member
    Posted 7 years ago
    #

    Here's a handy script trick...

    In maya we have "select all", "select all by type" and "select hierarchy". But not "select all, by type, IN hierarchy". A friend of mine asked me for this functionality a while ago, and I couldn't believe how useful it actually is. I use this a lot. Need to pick all the constraints for a character's right arm? Pick the top node of said right arm and BAM!

    I map these to marking menus triggered by a hotkey.

    cmds.select(cmds.ls(dag=1, ap=1, sl=1, type="joint"))
    cmds.select(cmds.ls(dag=1, ap=1, sl=1, type="nurbsCurve"))
    cmds.select(cmds.ls(dag=1, ap=1, sl=1, type="constraint"))

    If you're wondering how to get into scripting, this is a great example. Find that missing functionality in your workflow and try to create it from what's already there. I love this line of code in python, btw, it shows how you can nest commands together in the same line of code.

    Anyone else have some cool python or MEL tricks like this?

  2. Javier "Goosh" Solsona (admin)

    offline
    Key Master
    Posted 7 years ago
    #

    Nice..

    That got me thinking. How much do people use Python over MEL?

    I stopped using Maya before Python. Well, Python was just there, but it was the first incarnation and I never converted.

    Do people prefer Python?
    What about PyMel?

    Javier

  3. mzahmbie

    offline
    Member
    Posted 7 years ago
    #

    No tricks off hand to contribute, but I'll think on it! There's a lot of handy stuff you can do with Python. but to Javier's question.

    The game studio I'm at doesn't touch MEL anymore. With how much more you get from an object oriented language like Python we're all Python and going to all PyMel for anything that needs to be scripted to break out of any limitations involved by having to call MEL commands with Python. I know most of the game studios up here with the personnel to make the switch are currently or have already broken away from MEL too. It especially helps with the number of applications that Python can connect to now, you can use one language to talk to most of the programs used in the pipeline.

  4. Smapdi

    offline
    Member
    Posted 7 years ago
    #

    Yeah I think it's fair to say python is being more widely used. MEL, Python, pymel all tools in the toolbox. But yeah we are rewriting our MEL tools in pymel/python. We're even developing a custom python api for standardized code in and outside of Maya, it's really powerful and python is user friendly but powerful enough to compile into plugins and standalone applications.

  5. PixL

    offline
    Member
    Posted 7 years ago
    #

    Thanks for the tip.
    I'm not a heavy duty coder, but I like to write my own tools when I need extra functionality.
    I switched to Python earlier this year and wouldn't consider going back to MEL. PyMel is a great step in the right direction, but it is slow for some procedures and also if you share your scripts on creativecrash, others have to install PyMel for previous versions of Maya.

    Here's something useful that I've figure out:
    You can talk to a user-created-window from from the script editor.
    Simple Example:
    import pixL_varTest01
    reload (pixL_varTest01)

    print pixL_varTest01.varTest # Grab the var 'varTest' in the script 'pixL_testVar01'

    A practical use:
    Say you are programming and your tool has a scriptJob running. You can kill the scriptJob by closing the window, but that requires an extra step each time you change the code. So you assign the scriptJob to a var in the code, then you kill the scriptJob before using 'Reload':
    import pixL_SDKMonger
    scriptJob( kill=pixL_SDKMonger.SDKListenerJobNum, force=True)
    reload (pixL_SDKMonger)
    If you don't do this, the script won't reload correctly.

  6. Plywood-Pirate

    offline
    Member
    Posted 6 years ago
    #

    Hi there,

    then what is your advise for a guy just beginning with the art of rigging?
    Should I learn Python or MEL when it comes to scripting?

    I'm new to both languages, so it doesn't make any difference to me - and I have programming experience, so neither Python nor MEL will be impossible to learn for me. But I doubt that I have time to learn both, so which one would you go for?

    (Especially if I think about getting an intership for my bachelor degree in a character rigging position!?)

    Thanks,
    Micha

  7. Sam

    offline
    Member
    Posted 6 years ago
    #

    @Plywood_Pirate,

    I think i'm not wrong saying that you should go for python. I started to learn character setup two months ago and as you can guess i read through a lot of advice where to begin and if MEL or Python.
    Nearly everywhere i asked python was the advice to go.
    It's because python can be used on a wide range of different industries.

    L4l

  8. Javier "Goosh" Solsona (admin)

    offline
    Key Master
    Posted 6 years ago
    #

    Yeah. I even though MEL is probably way better integrated into Maya. Python is a better tool to know. It can be used not only in Maya but in tons of other applications.

    I would go with Python too

Reply

You must log in to post.

Rigging101 » Chit Chat12
1,099 posts in 307 topics over 110 months by 188 of 8,226 members. Latest: fashionpvp, d2q4p5z2j, gasheldonl