How to install/call Python Scripts?

How to install/call Python Scripts?

Anonymous
Not applicable
564 Views
2 Replies
Message 1 of 3

How to install/call Python Scripts?

Anonymous
Not applicable
Could someone please explain the installation of Python scripts?
I've created a simple script w/UI to lock joints during weight painting.
It has 2 procedures:
1) Open the UI - def pixl_jointLocker():
2) Execute a procedure to set the locked state of the joints - def lockEm():
All of the code works.

In my C:\Documents and Settings\Administrator\My Documents\maya\2010-x64\scripts\userSetup.py with this line:
import maya.cmds as cmds

I invoke the script with:
import pixl_jointLocker
pixl_jointLocker.pixl_jointLocker()


The interface appears.
I add joint names to the textFields, press the button which calls lockEm(), and I get:

# Error: NameError: line 1 of <maya console>: name 'lockEm' is not defined #
I've also invoked the script with:
import pixl_jointLocker
pixl_jointLocker.pixl_jointLocker&#40;&#41;
pixl_jointLocker.lockEm&#40;&#41;

I get the same error.
Thanks.
0 Likes
565 Views
2 Replies
Replies (2)
Message 2 of 3

Anonymous
Not applicable
suppose you have a module example.py that looks like this:

import maya.cmds as mc

def exampleWindow&#40;&#41;:
w = mc.window&#40;&#41;
mc.columnLayout&#40;&#41;
mc.button&#40;command='exampleFunction&#40;&#41;'&#41;
mc.setParent &#40;'..'&#41;
mc.showWindow&#40;w&#41;

def exampleFunction&#40;&#41;:
print &#40;'boo!'&#41;


then you could use

from example import *
exampleWindow&#40;&#41;
0 Likes
Message 3 of 3

Anonymous
Not applicable
Thanks for the reply.
After some fooling around w/the import and reload commands, I'm moving forward.
0 Likes