0

I've got a kind of weird question--but would be immensely useful if it is possible--in Maya using Python, can I take in several points of user input and have Python create a separate script for me? In this instance, I want to take in controller and locator names and have Python spit out a complete IKFK match script also in Python (it's really just a lot of getAttr and setAttr commands, although with 6 if statements per limb for PV matching.) The only other wrinkle there is that it has to be able to prefix hierarchy names in the script if necessary if the rig is imported into a new scene rather than just opened. There's an expression component to my switches that it would be nice if Python could make for me, too.

Is this possible or am I crazy?

1 Answer 1

1

That's no problem. Just write a textfile with a .py extension into a path where maya can find it. Then you have to import it somewhere. Creating expressions is not a problem either.

Maybe it could make sense to think about the approach you choose. Imagine you have written a dozen of these new python files and you discover a problem in the script, you will have to redo it. I'd try to collect all data and only write the required informations into a textfile e.g. in json format. Then you can read the data and rebuild your skeletons.

Sign up to request clarification or add additional context in comments.

7 Comments

thank you. What command(s) would I use to get Maya to do this? (preferably something that can be executed on a button press)
If you want to go the data file way, I'd first try to find out which data is needed. The I'd try to setup a python dictionary where you save all settings, e.g. myDict['joint1']['rotX'] = 123.4 then if you collected everything use json (e.g. json ) to serialize the dictionary and simply write it to disk with the usual python file commands.
the idea is that the user would provide the data (names of controls and locators, the amount of chains they have switches for (ie, if they just have them on the arms or arms and legs, etc) and then the format and actual content (if statements, loops, get/setAttr statements, etc) would be something not user provided. I kinda want it to do the tedious heavy lifting XD)
I apologize if I am annoying or anything, Python is not my strong suit even as a rigger
I heavily recommend python. Especially for a bit more complex scripts, it has a lot of benefits. Learn it, you will not regret it. Show your code and ask if you have problems.
|

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.