PDA

View Full Version : calling python like a global proc


tbaypaul
01-27-2007, 01:03 AM
I have created a folder called python in my maya user directory.
I have created a python path to it in my Maya.env.
I have my userSetup.py importing the maya.cmds on start up.

In my python folder I have the ubiquious helloWorld.py from Cory's blog on the area.

import maya.cmds as mc
def helloMaya():
'''a simple function to say hello maya. a user will see
whatever you put here when they ask for help on the function '''
print 'hello maya!'

From the maya docs I understand that to mimic the mel global behavior you import the file and call the def as a function.......eg

import helloWorld
helloWorld.helloWorld()

results in.....
# ImportError: No module named helloWorld #
# NameError: name 'helloWorld' is not defined #

the bonus tools house generator python script generated this echo when the command is
selected in the interface menu

python "from houseGenerator import *";python "houseGenerator()";
from houseGenerator import*
houseGenerator()

cpan
01-27-2007, 12:50 PM
if you're calling it from MEL then use the python MEL command to do that.

eg
python "import helloWorld";
python "helloWorld.helloMaya()";

tbaypaul
01-27-2007, 03:49 PM
thanks, but it was operator error...isn't it always......I was calling helloWorld, when it is named helloMaya !.....and I had a comma between my python paths, where you use a semicolon ; Argh.....

CGTalk Moderation
01-27-2007, 03:49 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.