Hello Everyone !
I hope you are all going well !
I am currently trying to write an Auto-Rig tool for maya.
I want to have different Python files, for every major tasks that needs to be done by the script.
For example : one file for the UI, one for the Joints generation, one for the Arm construction, and so on…
The problem is how to define variables within one file, and use the same variables within another file to create a precise number of fingers, for example.
I want my Auto-Rig to be versatile, in order to do that I need the user to choose between values, and so on…
I will use a simple example,
the user can choose between creating 1 or 2 cubes.
I wrote this to have a better understanding of the issue.
UI_Script :
import maya.cmds as mc
class Window_UI:
def Create_UI(self):
UI = mc.window(title='Auto-Rig Tool')
#Defining main layout
main_Layout = mc.menuBarLayout()
#Number of Cubes
oneCube = mc.checkBox('1 Cube', label='1 Cube')
twoCubes = mc.checkBox('2 Cubes', label='2 Cubes')
Create_Cube_Script :
import maya.cmds as mc
class Create_Cube:
def CC(self):
#Querying the value of the checkBox
#Do not need to know the value of the second checkbox as we only
# have 2 options possible
oneCube_Value = mc.checkBox(oneCube, query=True, value=True)
if (oneCube_Value):
number_of_cube = 1
else:
number_of_cube = 2
for x in range(number_of_cube):
mc.polyCube()
Launcher_Script :
import sys
#load the path of the python files
sys.path.append('G:\\3D2\\Script\\Class_Exp')
import UI_Script
import Create_Cube_Script
reload UI_Script
reload Create_Cube_Script
Here I want to have the value of the checkBox (from de the UI_Script), tu be queried and used by the Create_Cube_Script.
I do know it is possible to do pretty much this kind of thing with Class, but even after days of research, I did not manage to find an answer or a possible way to solve my issue.
Thank you very much for your time.
Cordially.