## Setting up SSH keys for SourceTree to push code again…

Thu, Apr 14th, 2016

This post is to remind us how to do this. J had a computer issue and had to reinstall Windows:)

1. Follow this tutorial – https://confluence.atlassian.com/bitbucket/set-up-ssh-for-mercurial-728138122.html
2. Make some coffee, you earned it.

If you get the “server’s host key is not cached…” error when attempting to push from SourceTree:

1. Command prompt
2. Go to Program Files (x86)/PuTTY
4. Hit ‘y’

## Getting geo from later versions of Maya to earlier versions…

Fri, Feb 19th, 2016

Sometimes you need to get stuff back to earlier versions of Maya and ignore version just doesn’t work. I needed to get a load of 2016 geo back to 2011. Here’s what worked:

1. Export geo to a clean file in your current version of Maya
2. If you can’t export it as an .ma file, run scene optimize on the mb file making sure to remove unknown nodes
3. Save as an .ma
4. In a text editor change the 2016(or whatever version you’re going from) to 2011(or whatever version you’re going to). Save it
5. Open in the earlier version of Maya

-j@cgm

## Why you should never use ‘print’ in your Maya tools and other optimization thoughts…

Tue, Sep 17th, 2013

First off, sorry for the big break in posts here. We’ve just been swamped working on Morpheus and haven’t posted much. This sounded like a good topic.

As we’re getting close to finishing up Morpheus 2, I’ve been trying to do some optimization in the code to make the build processes faster and other things. One of the questions I had was if log.debug was causing speed hits and what other affects prints or log.infos were having on our main code speeds.

What does one do when trying to solve something? Well, we make some hypotheses and tests for those hypotheses. Go, go 8th grade science!

So I wrote a test this morning and the results are rather interesting. I wrote a series of timed functions that do a pow calculation on an enumerated range. I gave the tester a single kw arg of setting the maxTest which sets the range end. I’ll post the tester code below.

The results on a 3000 range test are as follows:

• logger >> Time >> = 46.289 seconds
• debug >> Time >> = 24.752 seconds
• if debug >> Time >> = 0.000 seconds
• print >> Time >> = 150.508 seconds
• calc >> Time >> = 0.569 seconds

The raw calc is obviously the fastest.  What was curious to me was that debugs take a hit even when not printing. What was most crazy was how slow print statements are and concluded that you should pretty much never ever use them in maya tools.

For the purposes of our own debugging, using an if/debug gate on that info seemed like it was going to make the most sense. So with that in mind I tried a way to find the level of the logger. The only call I could initially find was log.getEffectiveLevel(). That seems to be the most intuitive method to get a if/debug check for free. Need to do more research to figure out if a level of 10 – which seems to be debug’s default integer value is a usable check.

On a whim I pulled all the log.debugs from our core code and the time savings was considerable on our unit tests. Blrgh…yet another item for the ever growing to do pile.

In the end these are my initial conclusions:

• Never use ‘print’ calls in maya python. Use logger – log.info
• Only raw log.debugs in when no calculations have to happen to form that report. I.e – they’ve already been done.
• I need to begin working to pull out as many debugs as possible and/or level-gate those calls for speed’s sake.
import time
import logging
logging.basicConfig()
log = logging.getLogger(__name__)
log.setLevel(logging.INFO)

def testDebugCalls(maxTest = 500):
ifDebug = False
def logTest():
_str_funcName = 'logger'
time_start = time.clock()
for i,n in enumerate(range(1,maxTest)):
log.info("log >>> %s"%(pow(n,i)))
return "%s >> Time >> = %0.3f seconds " % (_str_funcName,(time.clock()-time_start))
def debugTest():
_str_funcName = 'debug'
time_start = time.clock()
for i,n in enumerate(range(1,maxTest)):
log.debug("debug >>> %s"%(pow(n,i)))
return "%s >> Time >> = %0.3f seconds " % (_str_funcName,(time.clock()-time_start))
def ifDebugTest():
_str_funcName = 'if debug'
time_start = time.clock()
for i,n in enumerate(range(1,maxTest)):
if log.getEffectiveLevel() == 10:log.debug("debug EFFECTIVELEVEL >>> %s"%(pow(n,i)))
return "%s >> Time >> = %0.3f seconds " % (_str_funcName,(time.clock()-time_start))
def printTest():
_str_funcName = 'print'
time_start = time.clock()
for i,n in enumerate(range(1,maxTest)):
print("print >>> %s"%(pow(n,i)))
return "%s >> Time >> = %0.3f seconds " % (_str_funcName,(time.clock()-time_start))
def calcTest():
_str_funcName = 'calc'
time_start = time.clock()
for i,n in enumerate(range(1,maxTest)):
x = (pow(n,i))
return "%s >> Time >> = %0.3f seconds " % (_str_funcName,(time.clock()-time_start))

time_log = logTest()
time_debug = debugTest()
time_ifDebug = ifDebugTest()
time_print = printTest()
time_calc = calcTest()

for l in [time_log,time_debug,time_ifDebug,time_print,time_calc]:
print l

## cgm.ProblemKicker – 11.01.2012

Thu, Nov 1st, 2012

We’re trying out the name ProblemKicker. If anyone else had a better one, we’re all ears.

## This Week @ CGM

Wed, Jul 11th, 2012

Short and simple vid this week on how to install the tools. Prolly should have done this a while back.

Work has been coming along with the rigger, gotta say my rudimentary code from last year is just lousy. That’s why we learn and grow, no?

If you’ve missed it, we’re lookin for feedback on where to proceed next. If you’d like to give us your input, please fill out the form here:

http://www.cgmonks.com/public-input-july-2012/

## cgm.PolyUniteTool Preview

Fri, Apr 13th, 2012

Intro to a wip tool from cgm.tdTools. As you’ll see. Still wip

## Meet the Locinator!

Fri, Apr 6th, 2012

We got our first tool introduction video done. Bokser says I sound like the Bob Ross of CG. you be the judge. Enjoy it(or not).

In other news, making good progress with getting the first release pack ready to go. Knocking out bugs as we can.  If you wanna sign up to be a tester, there’s a link on the contact page.

## if maya.env(): return frustration…

Tue, Mar 27th, 2012

So at least to me, the maya.env setup has perpetually been an exercise in frustration. For years, it seemed it would remain shrouded in mystery. Recently as I’ve been making tools and learning I took some time to do some googling and I have a much better understanding of how to make it work  well so you don’t have to!

So, let’s set it up…

Homework first!

On a typical pc install, that will be ‘ \My Documents\maya\%version\’. In my case, it’s ‘X:\My Documents\maya\2011-x64’
2. Remember where you installed the cgmtools repository to

Let’s get to it.
Note – this is for a Windows setup

1. Make sure Maya is closed
2. The first thing we wanna add is an inline variable we can call. This doesn’t have to be done but with multiple repositories, I found it easier. We’ll add this to the top
REPOSPATH = X:/repos/
3. Then if you already have some paths on Maya_Script_Path or PythonPath, you can amend them by putting the following at the end of each one followed by a ‘;’
%REPOSPATH%/cgmtools/mayaTools; %REPOSPATH%/cgmtools/mayaTools;
4. Open up Maya and type the following in a mel command line:
cgmToolbox

Here’s an example of a clean maya.env with no other paths added.

[crayon]REPOSPATH = X:/repos/

MAYA_SCRIPT_PATH=%REPOSPATH%/cgmtools/mayaTools;

PYTHONPATH=%REPOSPATH%/cgmtools/mayaTools;[/crayon]

Thu, Mar 22nd, 2012

For users granted access to the repository for up-to-date tools and code this is run down on getting setup. Eventually we hope to have this all happen within Maya but for now, there’s some leg work. At present, we’re using bitbucket.org as our code repository in the git format. This is tailored to a pc user, if we get it figured out for others, we’ll add that here.

For a great immersive, tutorial on learning git, check out gitimmersion.

For the everyday pc user…

If you have one already, move along…
• Go through the tutorial to get a foundation on how stuff works.
• At a minimum, you need to install msysgit from the tutorial. We only need step one install stuff
• Get git permssion
For now, this is a invitation only thing. You’ll get an invite to the repository after which you can connect to it
• Decide where you wanna store stuff
For myself, I created a ‘repos’ folder on my ‘x’ drive as I sync to several repositories. So my path I’ll be going to via gitBash
• Get the git path
If you have permission, you can go to bit bucket and see the path to sync to to clone the repository
• Sync it up!
1. Open git bash
2. Browse to your directory to store stuff
3. Type in the clone command
5. Let it finish up and you should see something like…
Make sure it pulled everything
• Updating anytime is relatively straight forward anytime you please.
1. Git bash to the cgmtools folder
2. Type the following:
git checkout
4. Have a chocolate, you deserve it!

After you’ve done this step, time to setup your maya.env

## Wing IDE auto completion in maya…

Thu, Mar 22nd, 2012

…with as little hair pulling as possible…

So, setting up an IDE for doing coding is a pretty good idea if you’re gonna be doing a lot of it. My IDE of choice is Wing and it can be a little tricky getting things setup right for auto-completion. If you wanna get going with it, you can…

2. Add maya’s mayapy exec as a custom Python Executable in Project Properties>Enviornment
3. Add your repository as a custom Python path in the same section – in my case ‘J:\repos\cgmtools\mayaTools’
4. Next see their doc page for maya for help
1. I had to change one item for my own setup. Maya 2011’s pi file location ended up being:
C:\Program Files\Autodesk\Maya2011\devkit\other\pymel\extras\completion\pi
5. Add your own computer’s path in Preferences>SourceAnalysis>Advanced>Insert and put that path in there and you should be golden
If you have to generate your own pi files for whatever reason…
Start with the tutorial here to get you most of the way there.
1. Now, when get to the the part about the genmayapi thing, you’re gonna wanna edit it cause it won’t work off the bat depending on your version of Wing.
1. Lines 5 and 7 will need to be modifed to your version of Wing. In my case, it was ‘Wing IDE Personal 4.1’
2. Line 12 will again need soe work, in my case it was ‘Wing Personal 4’.
You can find the folder directly in windows at  C:\Users\%Name%\AppData\Roaming.
2.  After those fixes you should be able to run the genmayapi and finish out the tutorial without issue.
This was my genmayapi.py:

[crayon]import os
import sys
import maya.standalone

WING_DIR = r’c:\Program Files (x86)\Wing IDE Personal 4.1′
if not os.path.exists(WING_DIR):
WING_DIR = r’c:\Program Files\Wing IDE Personal 4.1′

sys.path.append(os.path.join(WING_DIR, ‘src’, ‘wingutils’))
import generate_pi

PI_FILES_DIR = os.path.join(os.environ[‘AppData’], ‘Wing Personal 4’, ‘pi-files’)
MOD_LIST = [
‘maya.OpenMaya’,
‘maya.OpenMayaAnim’,
‘maya.OpenMayaCloth’,
‘maya.OpenMayaFX’,
‘maya.OpenMayaMPx’,
‘maya.OpenMayaRender’,
‘maya.OpenMayaUI’,
‘maya.cmds’,
‘maya.standalone’,
]

def main():
maya.standalone.initialize()
for mod in MOD_LIST:
pi_filename = os.path.join(PI_FILES_DIR, os.sep.join(mod.split(‘.’)) + ‘.pi’)
if not os.path.isdir(os.path.dirname(pi_filename)):
os.makedirs(os.path.dirname(pi_filename))

print ‘Generating .pi file for’, mod

f = open(pi_filename, ‘w’)
try:
generate_pi.ProcessModule(mod, file=f)
finally:
f.close()

if __name__ == ‘__main__’:
main()
[/crayon]

Happy coding!