Calling a Python function from Maya

Remember running this from within Maya:

import objectRenamer

If we are sourcing a script which contains functions, you’ll notice that the script won’t run.  That’s because functions need to be evoked to run.  Lets update our import code in Maya and also do some housekeeping to keep the code clean and readable:

# Lets import the script, and to make things easier give it a nickname (as obr)
import objectRename as obr

# Then reload the script to account for any updates
reload(obr)

# Then call the function in the script - rename()
obr.rename()