Changing States Manually
There are some occasions when it’s useful for us to be able to push states and changes manually. Some of those times might be:
- Getting to the nitty gritty when troubleshooting a problem
- Testing new modules and changes
Error reporting is currently cleaner when you do it manually because of how the UI functions.
When we get to a MRS Maker’s Workshop on making your own rigBlocks, this whole section will get fleshed out in much more detail.
Loading CGM Python Modules
The first step is to load cgm modules locally so we can call them. There’s an easy way to do that via the ui.
Walking a module’s functions
Before we can do anything else we must know how to instance our rigBlock.
A few notes:
- We’ll be working in the script editor
- Make sure you have a python tab up
- In the script editor make sure the following are on:
[x] Show stack trace
[x] Line numbers in errors
So assuming we have a rigblock named:
We can run this in the script editor
b1 = cgmMeta.asMeta('L_eye_eyeBlock')
Now we have a python object we can use to call pretty much everything else.
You should check out cgmNode and cgmObject to get further information on what’s available.
b1.mNode#...dag handle using red9's MetaClass as our super b1.select() #...getting the rigbLock's module... b1.p_blockModule b1.getBlockModule()#...get's our block's python module. #Often used in conjunction with this when we're working through things.... reload(b1.p_blockModule)# Do this a lot when I'm testing changes in the code base.
Template to Skeleton
There’s two ways of doing this currently, you can use which syntax you prefer.
#...This code is to walk up and down the states. b1.UTILS.changeState(b1,'define') b1.UTILS.changeState(b1,'template') b1.UTILS.changeState(b1,'prerig') b1.UTILS.changeState(b1,'skeleton') #You can query state by: b1.getState()
There are specialized calls which I’ll get around to documenting as the code base solidifies.
I’ll loop back to hit this this later. There’s a lot to it. We utilize a rig class factory for processing the rig setup so that we can have a instance object to store to and do other data processing without bogging down our actual rigBlock metaClass.
When you want to set log levels on a module.
import cgm.core.mrs.RigBlocks as RIGBLOCKS RIGBLOCKS.log.setLevel(RIGBLOCKS.logging.DEBUG)#..debug mode on RIGBLOCKS.log.setLevel(RIGBLOCKS.logging.INFO)#...info mode on