Hello all! I am much newer to scripting in Python and my experience is almost exclusively limited to writing tools for use in a Maya production pipeline for which I am the exclusive author. So please excuse the rudimentary nature of the code! I am learning best practices as I go. :)
Here is my issue: I have a "toolsMain" script which I use to call functions from a "userInterfaceElements" script for UI element creation. From there, the commands on the buttons and widgets will call functions from a "modelingTools" script which I import as "MOD". When I run the scripts in Maya, the UI loads correctly, but when I press the "Merge" button on the UI window I get the following error: # Error: NameError: file <maya console> line 1: name 'MOD' is not defined # But I know it does. I have quadruple checked my spelling and syntax multiple times, and I am beginning to think something is happening that I don't quite understand and haven't seen before. I have successfully imported scripts, passed arguments between scripts and functions in the past, but this seems new and different and I can't quite figure it out. Any help would be greatly appreciated!!! Thanks in advance! The code for the 3 scripts is below in its simplest form for cut and paste purposes: "toolsMain.py" [python] import maya.cmds as mc import userInterfaceElements as ELEM reload (ELEM) def toolsMain (): if (mc.window("toolsWindowMain", exists = True)): mc.deleteUI("toolsWindowMain") toolsWindow = mc.window(title="Tools Window", iconName= "toolsWindow", widthHeight=(400, 500)) scrollMain = mc.scrollLayout("ScrollLayoutMain_01", w=390, hst=16, vst=16) tabsMain = mc.tabLayout("TabLayoutMain_01", imw=5, imh=5) ##TAB 1 - Main tab_1 = ELEM.stdColumnLayout("ColumnLayout_01", "TabLayoutMain_01") ## Modeling Frame ## ELEM.stdFrameLayout("ModelingFrame_01", "ColumnLayout_01", "Modeling") ELEM.stdRowColumnLayout("ModelingRowColumn_01", "ModelingFrame_01") #Modeling Buttons ELEM.modelingButton("MergeButton_01", "Merge", "merge", "MOD.doMergeWindow()") #Organize Tabs mc.tabLayout(tabsMain, edit=True, tabLabel=((tab_1, "Main"))) mc.showWindow(toolsWindow) [/python] "userInterfaceElements.py" [python] import maya.cmds as mc import modelingTools as MOD reload (MOD) def stdColumnLayout(name, daddy): #(name, parent) mc.columnLayout(name, parent=daddy, rowSpacing=5, columnWidth=390) return name def stdFrameLayout(name, daddy, callIt): #(name, parent, label) mc.frameLayout(name, parent=daddy, label=callIt, borderVisible=True, collapsable=True, width=390) def stdRowColumnLayout(name, daddy): #(name, parent) mc.rowColumnLayout(name, parent=daddy, numberOfColumns=3, rowSpacing=[10, 5]) def modelingButton(name, callIt, tip, runIt): #(name, label, annotation, command) toolTip = "DEFAULT" mc.button(name, parent="ModelingRowColumn_01", label=callIt, annotation=toolTip, command=runIt, enableBackground=True, backgroundColor=[0.68, 0.76, 0.66], width=125, height=30) [/python] "modelingTools.py" [python] def doMergeWindow (): print "POPPING UP A MERGE WINDOW NOW..." [/python] -- You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group. To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_maya+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/8eb43586-5a70-4380-b2f4-504d80e1c31d%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.