I am currently writting an Auto-rig tool and I am facing some issues.
I splitted my code in differnet part (ex : Module_Arms, Module_Joints, Module_UI, etc…)
Then sometimes I need to have access to variables created in one module, and use these variables within another module.
Here is an example to make it clear :
import sys sys.path.append('G:\\3D2\\Script\\Auto_Rig') import maya.cmds as mc class Class_Joints: # Creating arm Jnts and the list of it def gen_arms_joints(self): # Create Joints self.shoulderJnt = mc.joint(absolute=True, position=[5,8,0], n='L_Shoulder_Jnt') self.elbowJnt = mc.joint(absolute=True, position=[10,8,-1.5], n='L_Elbow_Jnt') self.wristJnt = mc.joint(absolute=True, position=[15,8,0], n='L_Wrist_Jnt') self.handcupJnt = mc.joint(absolute=True, position=[18,8,0], n='L_HandCup_Jnt') # Create list self.armsJntList = mc.ls(self.shoulderJnt, self.elbowJnt, self.wristJnt, self.handcupJnt) mc.select(clear=True)
Here is the Module_Joints that will create every Joints needed in the scene.
The goal here for example is to create controllers for each Arm_Joints.
Then , here is the seconde Module :
import sys sys.path.append('G:\\3D2\\Script\\Auto_Rig') import Module_Joints import maya.cmds as mc class Class_Fingers(object): # Initializing global variables def __init__(self): # Getting acces to the different modules self.Joints = Module_Joints.Class_Joints() # Rig Method def arms_rig_method(self): # Creating FK Controlers for finger_joint in self.Joints.armsJntList: mc.circle(normal=[1, 0, 0])
I import the modules needed (here Module_Joints), then I initialize it within the
I thought that writting something like
self.Joints.armsJntList would do the trick. But no.
I do miss some knowledge on python class and I hope that you would be able to help me there.
Thank you for your time.