<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>MathiesonFacer.com</title>
	<atom:link href="http://www.mathiesonfacer.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.mathiesonfacer.com</link>
	<description>Mathieson Facer - Rigging Technical Director</description>
	<lastBuildDate>Mon, 26 Nov 2012 16:22:54 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.5.1</generator>
		<item>
		<title>Getting wraps to scale in 3DS Max and Maya</title>
		<link>http://www.mathiesonfacer.com/featured/getting-wraps-to-scale-in-3ds-max-and-maya/</link>
		<comments>http://www.mathiesonfacer.com/featured/getting-wraps-to-scale-in-3ds-max-and-maya/#comments</comments>
		<pubDate>Mon, 26 Nov 2012 16:22:54 +0000</pubDate>
		<dc:creator>Mat</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[Featured]]></category>
		<category><![CDATA[Tutorials]]></category>

		<guid isPermaLink="false">http://www.mathiesonfacer.com/?p=1358</guid>
		<description><![CDATA[There is annoying behaviour that exists for wraps in both 3DS Max and Maya. When wrapping geometry to an influence that is scaling at the component/sub-object level, the thickness of the wrapped geometry does not scale and the mesh becomes jagged when reaching certain thresholds. It makes sense since polygons do not actually have any thickness, however, [...]]]></description>
				<content:encoded><![CDATA[<p>There is annoying behaviour that exists for wraps in both 3DS Max and Maya. When wrapping geometry to an influence that is scaling at the component/sub-object level, the thickness of the wrapped geometry does not scale and the mesh becomes jagged when reaching certain thresholds. It makes sense since polygons do not actually have any thickness, however, this is bad news for making your rigs scalable.</p>
<p>I was having trouble finding a solution to the problem when searching the internet. The best solution I found was to pass the wrapped geometry through a blendshape node and then scale that node. This was not a suitable solution for what I needed as the rig I was dealing with had far too many wraps. It would have meant a huge pain to get working and also a much slower rig in the end.</p>
<p><span id="more-1358"></span></p>
<p>After lots of trial and error, I was able to find a solution to fit my needs. It is fairly simple in the end, and it doesn&#8217;t create a huge amount of overhead. Please watch the following video to see how to get it working. <a href="http://www.mathiesonfacer.com/wp-content/sampleFiles/wrapScalingSampleFiles.zip">Download sample files by clicking here.</a></p>
<iframe src="http://player.vimeo.com/video/54270889??title=0&byline=0&portrait=0" width="604" height="370" frameborder="0" marginwidth="0" marginheight="0"></iframe>
]]></content:encoded>
			<wfw:commentRss>http://www.mathiesonfacer.com/featured/getting-wraps-to-scale-in-3ds-max-and-maya/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Faster setAttr for skin weights using MayaPy</title>
		<link>http://www.mathiesonfacer.com/tutorials/faster-setattr-for-skin-weights-using-mayapy/</link>
		<comments>http://www.mathiesonfacer.com/tutorials/faster-setattr-for-skin-weights-using-mayapy/#comments</comments>
		<pubDate>Fri, 05 Oct 2012 07:18:41 +0000</pubDate>
		<dc:creator>Mat</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[Maya]]></category>
		<category><![CDATA[Python]]></category>
		<category><![CDATA[Tools]]></category>
		<category><![CDATA[Tutorials]]></category>

		<guid isPermaLink="false">http://www.mathiesonfacer.com/?p=1343</guid>
		<description><![CDATA[I&#8217;ve been working on writing a skin weights importer/exporter the past few days. Searching online for what the fastest methods are, all I could find were web pages stating that setAttr was the fastest method for setting skin weights. Unfortunately for me, this is already what I was using and it was far too slow. [...]]]></description>
				<content:encoded><![CDATA[<p>I&#8217;ve been working on writing a skin weights importer/exporter the past few days. Searching online for what the fastest methods are, all I could find were web pages stating that setAttr was the fastest method for setting skin weights. Unfortunately for me, this is already what I was using and it was far too slow. After trying many different approaches for trying to improve speed, most of which were failures and none of which were fast enough, I created a simple poly cube, a two joint chain, skinned the cube to the joints and then saved out an ma file. This lead to quite the epic discovery.</p>
<p>This whole time that I was using setAttr, I could not understand why I was not able to just set all weights for a vert rather than having to assign a weight for each influence affecting each vert. This, I knew for certain, was what was slowing me down. I went through the same song and dance when collecting the skin weights: doing a getAttr on weightList[#].weights[#] for every single vert and influence was slow, but doing a getAttr on weightList[#].weights was fast. Made good sense. However, whenever I tried to do a setAttr on weightList[#].weights I would receive an error message telling me they had to be set individually. This is what the simple ma file helped me get around.</p>
<p><span id="more-1343"></span></p>
<p>It turns out, you <em>can </em>setAttr on weightList[#].weights! Well, sort of. You can do it on a range of influences in one go. There are just a few tricks. Here is an example of the proper syntax in order to do this:</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="python" style="font-family:monospace;">cmds.<span style="color: black;">setAttr</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'skinCluster1.weightList[0].weights[0:2]'</span><span style="color: #66cc66;">,</span> <span style="color: #ff4500;">0.2</span><span style="color: #66cc66;">,</span> <span style="color: #ff4500;">0.2</span><span style="color: #66cc66;">,</span> <span style="color: #ff4500;">0.6</span><span style="color: black;">&#41;</span></pre></td></tr></table></div>

<p>You must specify the range of influences after weights, and the provide the weight values individually.<br />
If you have weights assigned to another influence object for that same vertex, but it is not sequential to the other influences involved, you must do this in a separate setAttr call.</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="python" style="font-family:monospace;">cmds.<span style="color: black;">setAttr</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'skinCluster1.weightList[0].weights[0:2]'</span><span style="color: #66cc66;">,</span> <span style="color: #ff4500;">0.2</span><span style="color: #66cc66;">,</span> <span style="color: #ff4500;">0.2</span><span style="color: #66cc66;">,</span> <span style="color: #ff4500;">0.2</span><span style="color: black;">&#41;</span>
cmds.<span style="color: black;">setAttr</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'skinCluster1.weightList[0].weights[6]'</span><span style="color: #66cc66;">,</span> <span style="color: #ff4500;">0.4</span><span style="color: black;">&#41;</span></pre></td></tr></table></div>

<p>I saw significant speed improvements using this method over the previous method of setting each influence individually. The mesh I was testing on went from a load titime of 67 seconds down to 15 seconds. This offers some definite speed improvements.<br />
In order to do this, of course, you need to be able to sort your data into sequences and then feed it to the setAttr command. Here is a simple method for converting a list of numbers to a nested list of sequences using those numbers:</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="python" style="font-family:monospace;"><span style="color: #ff7700;font-weight:bold;">from</span> <span style="color: #dc143c;">itertools</span> <span style="color: #ff7700;font-weight:bold;">import</span> izip
&nbsp;
<span style="color: #ff7700;font-weight:bold;">def</span> getRangesFromIntegers<span style="color: black;">&#40;</span>integers<span style="color: #66cc66;">,</span> flat<span style="color: #66cc66;">=</span><span style="color: #008000;">False</span><span style="color: black;">&#41;</span>:
	currentRange <span style="color: #66cc66;">=</span> <span style="color: black;">&#91;</span>integers<span style="color: black;">&#91;</span><span style="color: #ff4500;">0</span><span style="color: black;">&#93;</span><span style="color: black;">&#93;</span>
	offsetInts <span style="color: #66cc66;">=</span> integers<span style="color: black;">&#91;</span><span style="color: #ff4500;">1</span>:<span style="color: black;">&#93;</span>
	ranges <span style="color: #66cc66;">=</span> <span style="color: black;">&#91;</span>currentRange<span style="color: black;">&#93;</span>
	<span style="color: #ff7700;font-weight:bold;">for</span> currentInt<span style="color: #66cc66;">,</span> previousInt <span style="color: #ff7700;font-weight:bold;">in</span> izip<span style="color: black;">&#40;</span>offsetInts<span style="color: #66cc66;">,</span> integers<span style="color: black;">&#41;</span>:
		<span style="color: #ff7700;font-weight:bold;">if</span> currentInt - previousInt <span style="color: #66cc66;">==</span> <span style="color: #ff4500;">1</span>:
			currentRange.<span style="color: black;">append</span><span style="color: black;">&#40;</span>currentInt<span style="color: black;">&#41;</span>
		<span style="color: #ff7700;font-weight:bold;">else</span>:
			currentRange <span style="color: #66cc66;">=</span> <span style="color: black;">&#91;</span>currentInt<span style="color: black;">&#93;</span>
			ranges.<span style="color: black;">append</span><span style="color: black;">&#40;</span>currentRange<span style="color: black;">&#41;</span>
	<span style="color: #ff7700;font-weight:bold;">if</span> flat:
		<span style="color: #ff7700;font-weight:bold;">return</span> <span style="color: black;">&#91;</span><span style="color: #008000;">tuple</span><span style="color: black;">&#40;</span>rng<span style="color: black;">&#41;</span> <span style="color: #ff7700;font-weight:bold;">for</span> rng <span style="color: #ff7700;font-weight:bold;">in</span> ranges<span style="color: black;">&#93;</span>
	<span style="color: #ff7700;font-weight:bold;">else</span>:
		returnRanges <span style="color: #66cc66;">=</span> <span style="color: black;">&#91;</span><span style="color: black;">&#93;</span>
		<span style="color: #ff7700;font-weight:bold;">for</span> rng <span style="color: #ff7700;font-weight:bold;">in</span> ranges:
			<span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: #008000;">len</span><span style="color: black;">&#40;</span>rng<span style="color: black;">&#41;</span> &amp;gt<span style="color: #66cc66;">;</span> <span style="color: #ff4500;">1</span>:
				returnRanges.<span style="color: black;">append</span><span style="color: black;">&#40;</span><span style="color: #008000;">tuple</span><span style="color: black;">&#40;</span><span style="color: black;">&#91;</span><span style="color: #008000;">min</span><span style="color: black;">&#40;</span>rng<span style="color: black;">&#41;</span><span style="color: #66cc66;">,</span> <span style="color: #008000;">max</span><span style="color: black;">&#40;</span>rng<span style="color: black;">&#41;</span><span style="color: black;">&#93;</span><span style="color: black;">&#41;</span><span style="color: black;">&#41;</span>
			<span style="color: #ff7700;font-weight:bold;">else</span>:
				returnRanges.<span style="color: black;">append</span><span style="color: black;">&#40;</span><span style="color: #008000;">tuple</span><span style="color: black;">&#40;</span>rng<span style="color: black;">&#41;</span><span style="color: black;">&#41;</span>
		<span style="color: #ff7700;font-weight:bold;">return</span> returnRanges</pre></td></tr></table></div>

<p>What you need to do after getting your sequences is collect your weights in these same groups. Its not difficult, so I am just going to leave that up to you to figure out. It may depend on how you collected your weight data though. If you have any questions, just leave a comment below. Once you have your weight data, you just need to pass everything to the setAttr command. It would look something as follows:</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="python" style="font-family:monospace;"><span style="color: #ff7700;font-weight:bold;">for</span> myRange<span style="color: #66cc66;">,</span> myWeights <span style="color: #ff7700;font-weight:bold;">in</span> <span style="color: black;">&#123;</span><span style="color: black;">&#40;</span><span style="color: #ff4500;">0</span><span style="color: #66cc66;">,</span><span style="color: #ff4500;">2</span><span style="color: black;">&#41;</span>:<span style="color: black;">&#91;</span><span style="color: #ff4500;">0.2</span><span style="color: #66cc66;">,</span> <span style="color: #ff4500;">0.2</span><span style="color: #66cc66;">,</span> <span style="color: #ff4500;">0.5</span><span style="color: black;">&#93;</span><span style="color: #66cc66;">,</span> <span style="color: black;">&#40;</span><span style="color: #ff4500;">8</span><span style="color: #66cc66;">,</span><span style="color: black;">&#41;</span>:<span style="color: black;">&#91;</span><span style="color: #ff4500;">0.1</span><span style="color: black;">&#93;</span><span style="color: black;">&#125;</span>.<span style="color: black;">iteritems</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>:
    myStrRange <span style="color: #66cc66;">=</span> <span style="color: black;">&#91;</span><span style="color: #008000;">str</span><span style="color: black;">&#40;</span>ind<span style="color: black;">&#41;</span> <span style="color: #ff7700;font-weight:bold;">for</span> ind <span style="color: #ff7700;font-weight:bold;">in</span> myRange<span style="color: black;">&#93;</span>
    cmds.<span style="color: black;">setAttr</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'skinCluster1.weightList[0].weights[%s]'</span> % <span style="color: #483d8b;">':'</span>.<span style="color: black;">join</span><span style="color: black;">&#40;</span>myStrRange<span style="color: black;">&#41;</span><span style="color: #66cc66;">,</span> *myWeights<span style="color: black;">&#41;</span></pre></td></tr></table></div>

<p>If you are unfamiliar with the * in front of myWeights and what it is doing, this is commonly used when inheriting classes and overriding class methods. It allows us, here, to pass a list of values to the setAttr command and have them be automatically unpacked. The first iteration of this loop will essentially look exactly like this:</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="python" style="font-family:monospace;">cmds.<span style="color: black;">setAttr</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'skinCluster1.weightList[0].weights[0:2]'</span><span style="color: #66cc66;">,</span> <span style="color: #ff4500;">0.2</span><span style="color: #66cc66;">,</span> <span style="color: #ff4500;">0.2</span><span style="color: #66cc66;">,</span> <span style="color: #ff4500;">0.5</span><span style="color: black;">&#41;</span></pre></td></tr></table></div>

<p>I don&#8217;t know if this is what other people have been doing already. Maybe it is. I didn&#8217;t see it mentioned anywhere in my searching though, so I hope this ends up being of help to some people!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.mathiesonfacer.com/tutorials/faster-setattr-for-skin-weights-using-mayapy/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>DoubleBarrel &#8211; Shotgun API Wrapper</title>
		<link>http://www.mathiesonfacer.com/blog/doublebarrel-shotgun-api-wrapper/</link>
		<comments>http://www.mathiesonfacer.com/blog/doublebarrel-shotgun-api-wrapper/#comments</comments>
		<pubDate>Mon, 28 May 2012 02:57:50 +0000</pubDate>
		<dc:creator>Mat</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[Shotgun]]></category>
		<category><![CDATA[Tools]]></category>

		<guid isPermaLink="false">http://www.mathiesonfacer.com/?p=1331</guid>
		<description><![CDATA[I have finally released my first Shotgun API wrapper (I have another one that won&#8217;t be coming for another while yet). This one is called DoubleBarrel, and it is called that because it provides two methods of connecting to the Shotgun database. This wrapper is intended mainly for tools that will connect to Shotgun to [...]]]></description>
				<content:encoded><![CDATA[<p>I have finally released my first Shotgun API wrapper (I have another one that won&#8217;t be coming for another while yet). This one is called DoubleBarrel, and it is called that because it provides two methods of connecting to the Shotgun database.</p>
<p>This wrapper is intended mainly for tools that will connect to Shotgun to retrieve one piece of data and then disconnect. Think tools like frame-range fetchers for when a scene is opened in Maya or Nuke. The wrapper will provide good speed improvements in these scenarios.</p>
<p><span id="more-1331"></span></p>
<p>I discovered, after using Shotgun&#8217;s API for a while, that I was often experiencing slow initialization/connection times. Sometimes I would be waiting 5 seconds or so when creating a Shotgun object. It got me thinking that perhaps I could create a Shotgun object before hand and just pass my Shotgun commands to it, bypassing the initialization and connection process for the Shotgun object. That is basically what this wrapper does. You need to create a DoubleBarrelServer and have that script running on another machine on your network. Then, when you create a DoubleBarrel object, you just need to provide the host and port information that you provided to the DoubleBarrelServer when initializing it, and rather than connecting directly to the Shotgun database you will instead connect to the DoubleBarrelServer and send your requests through it.</p>
<p>Have a look at the README on the GitHub page below, and let me know if there are any questions. I can provide more documentation, if needed. The serverTest and wrapperTest files in the tests package provide an example scenario of how to use. DoubleBarrel is also easily implemented into existing Python tools using the Shotgun API. The structure of DoubleBarrel is identical to that of the regular Shotgun API, so all you need to do is change the line in your code where you are importing the Shotgun class to instead import the DoubleBarrel class as Shotgun, and then provide the host and port information when creating an instance of the Shotgun class.</p>
<p><a href="https://github.com/Mathieson/DoubleBarrel">GitHub page for DoubleBarrel</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.mathiesonfacer.com/blog/doublebarrel-shotgun-api-wrapper/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Another go with Maya Muscle</title>
		<link>http://www.mathiesonfacer.com/featured/another-go-with-maya-muscle/</link>
		<comments>http://www.mathiesonfacer.com/featured/another-go-with-maya-muscle/#comments</comments>
		<pubDate>Thu, 10 May 2012 04:29:03 +0000</pubDate>
		<dc:creator>Mat</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[Featured]]></category>

		<guid isPermaLink="false">http://www.mathiesonfacer.com/?p=1324</guid>
		<description><![CDATA[I used the Maya Muscle system again recently and had a great time with it. I started with the simple muscle builder again this time, but was lucky to be working with someone who had more experience with Maya Muscle than I did. I followed her advice and abandoned the simple muscle builder and went [...]]]></description>
				<content:encoded><![CDATA[<div>I used the Maya Muscle system again recently and had a great time with it. I started with the simple muscle builder again this time, but was lucky to be working with someone who had more experience with Maya Muscle than I did. I followed her advice and abandoned the simple muscle builder and went the route of the muscle creator instead. No regrets. She gave me some other pointers as well, which were great, and pointed me in the direction of the full instruction manual for Maya Muscle. This was huge as I was not able to find it before despite searching in the past. The closest I had come previously was finding a chapter from it on Google. This was super handy to have and I can&#8217;t believe I wasn&#8217;t able to find it on my own. I have no idea why it was so hard. The link was even <a href="http://usa.autodesk.com/adsk/servlet/index?siteID=123112&amp;id=13710022&amp;linkID=9242256">missing from Autodesk&#8217;s website</a> <wbr>when I was there looking for documentation. <a href="http://images.autodesk.com/adsk/files/muscle.pdf">Here is the link for the full manual.</a></wbr></div>
<div></div>
<p><span id="more-1324"></span></p>
<div>Although my experience was great this time around, I still ran into many problems and, what seemed to be, bugs:</div>
<div>
<ul>
<li>Mirroring muscles across would not always work. Sometimes some of the locators would be mirrored into the wrong spot even though the rest of the muscle was correct. This meant that I couldn&#8217;t even correct the misplaced locator, because doing so would then ruin the rest of my muscle set up.</li>
<li>I found problems when duplicating nurbs surfaces that I had added a muscle shape node to. It would duplicate the muscle shape node as well, but not rename it. It would create a naming conflict, so I would go and rename it manually. Unfortunately this then lead to the muscle object being able to get added to the muscle deformer but not actually have any affect even when weights were painted to it. It took a while before I realized this was happening and was a pain to fix when it did happen. I had to remove the muscle from the solution, delete the muscle shape node, and then re-initialize the nurbs object as a muscle again.</li>
<li>For some reason, removing a muscle object from a deformer takes forever. It literally takes about 10 times as long as it takes to add it to the solution. Most of the time it would completely mangle my mesh when it finished the process and I would then have to re-open my scene and start again. It was a huge pain in the ass. I found a easier and safer approach was to save out my weight maps, delete the actual muscle deformer, re-add it, re-add all the muscle objects, and then load the weight maps back on. This was a manual process, but as I said was surprisingly much faster. It also did not lead to my mesh exploding randomly.</li>
<li>Mirroring weights over was a bit of a pain because, unfortunately, there were a few muscles created that I failed to name with the correct convention. Each muscle that is created with the muscle creator consists of at least 47 nodes. Each one of these nodes then has to be renamed. I must have been doing something wrong because some problems would start popping up after attempting to rename all these nodes. Anyways, the inconsistency in naming convention was a real pain because the weight mirroring tools expect you to pass in a left and right side string to help associate left and right side muscles. The left and right side strings is exactly what I failed on keeping consistent. There were two different identifiers being used: _l_/_r_ and _L/_R. When doing the _l_/_r_ it would detect all muscles matching that convention, but then fail on any matching the _L/_R. Naturally, you would then attempt mirroring using the _L/_R identifiers to do whatever was missed. The problem here is, it mirrors the weights for all muscles. It will, in this case, succeed for all of the _L/_R muscles, but incorrectly mirror the _l_/_r_ now. I wish there was some other way for Maya Muscle to form that left side/right side associations to avoid situations like this. I am going to have to look further into a solid way of renaming entire muscles so situations like this can be easier to address in the future. There is an option in the Muscle menu to delete one of these muscles and all of its associated nodes, but I could not find anything for renaming. Very puzzling.</li>
</ul>
<p>That is all for now. I know there was more that I ran into, but I cannot recall at the moment. Overall, I enjoyed working with it very much and the end result looked pretty nice. I am considering the above points just a learning experience, as I still have not used the system excessively. Like anything else, you have to learn the in and outs over time. I feel like I learned a lot of them through this most recent experience.</p>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.mathiesonfacer.com/featured/another-go-with-maya-muscle/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Python module &#8211; recursiveReload</title>
		<link>http://www.mathiesonfacer.com/tools/maya/python-module-recursivereload/</link>
		<comments>http://www.mathiesonfacer.com/tools/maya/python-module-recursivereload/#comments</comments>
		<pubDate>Wed, 29 Feb 2012 06:48:28 +0000</pubDate>
		<dc:creator>Mat</dc:creator>
				<category><![CDATA[Maya]]></category>
		<category><![CDATA[Python]]></category>

		<guid isPermaLink="false">http://www.mathiesonfacer.com/?p=1271</guid>
		<description><![CDATA[Something that bothered me when I first started working with Python in Maya was reloading of modules. When working on tools that have multiple modules importing each other, it can be a pain to have to change something in one of the imported modules. There are a number of situations that arise where your modules [...]]]></description>
				<content:encoded><![CDATA[<p>Something that bothered me when I first started working with Python in Maya was reloading of modules. When working on tools that have multiple modules importing each other, it can be a pain to have to change something in one of the imported modules. There are a number of situations that arise where your modules just do not reload correctly. You might have imported an object from a module, or you might have imported a method with the same name as the module you imported it from, or you might have imported using an alias.</p>
<p>A situation came up last week at work that was somewhat related to this issue. Another one of the TDs was in the process of writing a daemon script, and we needed a way of ensuring that all of our modules get updated automatically without re-starting the daemon every single time we commit a change.</p>
<p><span id="more-1271"></span></p>
<p>I came up with a quick solution before leaving for the weekend, but I felt there was a better solution available. I decided to take on a small home project over the weekend to come up with a more robust solution. With a bit of playing around I came up with a recursive solution utilizing the inspect module that seems to be working pretty well, so I thought I&#8217;d share :).</p>
<p>recursiveReload.py:</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="python" style="font-family:monospace;"><span style="color: #483d8b;">'''
Created on 2012-02-25
&nbsp;
@author: Mat
'''</span>
&nbsp;
<span style="color: #ff7700;font-weight:bold;">import</span> <span style="color: #dc143c;">sys</span>
<span style="color: #ff7700;font-weight:bold;">import</span> <span style="color: #dc143c;">inspect</span>
&nbsp;
<span style="color: #ff7700;font-weight:bold;">from</span> <span style="color: #dc143c;">distutils</span> <span style="color: #ff7700;font-weight:bold;">import</span> sysconfig
<span style="color: #ff7700;font-weight:bold;">from</span> <span style="color: #dc143c;">types</span> <span style="color: #ff7700;font-weight:bold;">import</span> ModuleType
&nbsp;
_processedModules <span style="color: #66cc66;">=</span> <span style="color: #008000;">set</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
_importedModules <span style="color: #66cc66;">=</span> <span style="color: #008000;">set</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
_remappingData <span style="color: #66cc66;">=</span> <span style="color: #008000;">list</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
&nbsp;
<span style="color: #ff7700;font-weight:bold;">class</span> ImportRemapData<span style="color: black;">&#40;</span><span style="color: #008000;">object</span><span style="color: black;">&#41;</span>:
&nbsp;
    <span style="color: #ff7700;font-weight:bold;">def</span> <span style="color: #0000cd;">__init__</span><span style="color: black;">&#40;</span>
        <span style="color: #008000;">self</span><span style="color: #66cc66;">,</span>
        destModuleName<span style="color: #66cc66;">,</span>
        destAttrName<span style="color: #66cc66;">,</span>
        sourceModuleName<span style="color: #66cc66;">,</span>
        sourceAttrName<span style="color: #66cc66;">,</span>
        attrType
        <span style="color: black;">&#41;</span>:
&nbsp;
        <span style="color: #008000;">self</span>._destModuleName <span style="color: #66cc66;">=</span> destModuleName
        <span style="color: #008000;">self</span>._destAttrName <span style="color: #66cc66;">=</span> destAttrName
        <span style="color: #008000;">self</span>._sourceModuleName <span style="color: #66cc66;">=</span> sourceModuleName
        <span style="color: #008000;">self</span>._sourceAttrName <span style="color: #66cc66;">=</span> sourceAttrName
        <span style="color: #008000;">self</span>._attrType <span style="color: #66cc66;">=</span> attrType
&nbsp;
    <span style="color: #ff7700;font-weight:bold;">def</span> remap<span style="color: black;">&#40;</span><span style="color: #008000;">self</span><span style="color: black;">&#41;</span>:
        <span style="color: #483d8b;">'''
        This gets the new modules and assigns the new attr value to the
        attr name in the new destination module.
        '''</span>
&nbsp;
        <span style="color: #808080; font-style: italic;">#get the newly reloaded source module and then the new attr value</span>
        sourceModule <span style="color: #66cc66;">=</span> <span style="color: #dc143c;">sys</span>.<span style="color: black;">modules</span><span style="color: black;">&#91;</span><span style="color: #008000;">self</span>._sourceModuleName<span style="color: black;">&#93;</span>
&nbsp;
        <span style="color: #808080; font-style: italic;">#we need to get the new attr value as well</span>
        newAttrVal <span style="color: #66cc66;">=</span> <span style="color: #008000;">None</span>
        <span style="color: #808080; font-style: italic;">#if the new attr val is a module, we need to get the module from sys</span>
        <span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: #008000;">self</span>._attrType <span style="color: #66cc66;">==</span> ModuleType:
            newAttrVal <span style="color: #66cc66;">=</span> <span style="color: #dc143c;">sys</span>.<span style="color: black;">modules</span><span style="color: black;">&#91;</span><span style="color: #008000;">self</span>._sourceAttrName<span style="color: black;">&#93;</span>
        <span style="color: #808080; font-style: italic;">#otherwise, just get it from the new source module</span>
        <span style="color: #ff7700;font-weight:bold;">else</span>:
            newAttrVal <span style="color: #66cc66;">=</span> <span style="color: #008000;">getattr</span><span style="color: black;">&#40;</span>sourceModule<span style="color: #66cc66;">,</span> <span style="color: #008000;">self</span>._sourceAttrName<span style="color: black;">&#41;</span>
&nbsp;
        <span style="color: #808080; font-style: italic;">#get the newly reloaded destination module and set the new attr value</span>
        destModule <span style="color: #66cc66;">=</span> <span style="color: #dc143c;">sys</span>.<span style="color: black;">modules</span><span style="color: black;">&#91;</span><span style="color: #008000;">self</span>._destModuleName<span style="color: black;">&#93;</span>
        <span style="color: #008000;">setattr</span><span style="color: black;">&#40;</span>destModule<span style="color: #66cc66;">,</span> <span style="color: #008000;">self</span>._destAttrName<span style="color: #66cc66;">,</span> newAttrVal<span style="color: black;">&#41;</span>
&nbsp;
<span style="color: #ff7700;font-weight:bold;">def</span> recursiveReload<span style="color: black;">&#40;</span>module<span style="color: #66cc66;">,</span> debug<span style="color: #66cc66;">=</span><span style="color: #008000;">False</span><span style="color: black;">&#41;</span>:
&nbsp;
    <span style="color: #808080; font-style: italic;">#get all of the data necessary for full reload of the module</span>
    _getModuleData<span style="color: black;">&#40;</span>module<span style="color: black;">&#41;</span>
&nbsp;
    <span style="color: #808080; font-style: italic;">#reload all of the collected modules</span>
    <span style="color: #ff7700;font-weight:bold;">for</span> importedModule <span style="color: #ff7700;font-weight:bold;">in</span> _importedModules:
        <span style="color: #ff7700;font-weight:bold;">if</span> debug:
            <span style="color: #ff7700;font-weight:bold;">print</span> <span style="color: #483d8b;">'Reloading module: %s'</span> % importedModule
        <span style="color: #008000;">reload</span><span style="color: black;">&#40;</span>importedModule<span style="color: black;">&#41;</span>
&nbsp;
    <span style="color: #808080; font-style: italic;">#now that the modules are all reloaded, re-map the extra data</span>
    <span style="color: #ff7700;font-weight:bold;">for</span> remapData <span style="color: #ff7700;font-weight:bold;">in</span> _remappingData:
        remapData.<span style="color: black;">remap</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
&nbsp;
    <span style="color: #808080; font-style: italic;">#clear our variables for future use</span>
    _processedModules.<span style="color: black;">clear</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
    _importedModules.<span style="color: black;">clear</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
    <span style="color: #ff7700;font-weight:bold;">del</span> _remappingData<span style="color: black;">&#91;</span>:<span style="color: black;">&#93;</span>
&nbsp;
    <span style="color: #ff7700;font-weight:bold;">return</span> <span style="color: #008000;">True</span>
&nbsp;
<span style="color: #ff7700;font-weight:bold;">def</span> _getModuleData<span style="color: black;">&#40;</span>module<span style="color: black;">&#41;</span>:
    <span style="color: #483d8b;">'''
    Inspects the module and all of its sub-modules to get all imported modules
    and data required for us to re-map variables properly.
    '''</span>
&nbsp;
    <span style="color: #808080; font-style: italic;">#add this module to the list of processed modules so we do not try to</span>
    <span style="color: #808080; font-style: italic;">#process it again and risk getting into an infinite loop</span>
    _processedModules.<span style="color: black;">add</span><span style="color: black;">&#40;</span>module<span style="color: black;">&#41;</span>
&nbsp;
    <span style="color: #808080; font-style: italic;">#get all attr names from the module</span>
    attrNames <span style="color: #66cc66;">=</span> <span style="color: #008000;">dir</span><span style="color: black;">&#40;</span>module<span style="color: black;">&#41;</span>
&nbsp;
    detectedModules <span style="color: #66cc66;">=</span> <span style="color: #008000;">set</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
    <span style="color: #ff7700;font-weight:bold;">for</span> attrName <span style="color: #ff7700;font-weight:bold;">in</span> attrNames:
&nbsp;
        <span style="color: #808080; font-style: italic;">#get attr value and try to get the module where the value originated from</span>
        attrVal <span style="color: #66cc66;">=</span> <span style="color: #008000;">getattr</span><span style="color: black;">&#40;</span>module<span style="color: #66cc66;">,</span> attrName<span style="color: black;">&#41;</span>
        attrModule <span style="color: #66cc66;">=</span> <span style="color: #dc143c;">inspect</span>.<span style="color: black;">getmodule</span><span style="color: black;">&#40;</span>attrVal<span style="color: black;">&#41;</span>
&nbsp;
        <span style="color: #808080; font-style: italic;">#if we didn't get a module returned, we are dealing with a builtin, or</span>
        <span style="color: #808080; font-style: italic;">#we are dealing with this module skip to the next loop iteration.</span>
        <span style="color: #808080; font-style: italic;">#We need to do two checks for builtin modules, if it is in the builtin</span>
        <span style="color: #808080; font-style: italic;">#module names and if it does not have a __file__ attr.</span>
        <span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: #ff7700;font-weight:bold;">not</span> attrModule \
        <span style="color: #ff7700;font-weight:bold;">or</span> attrModule.__name__ <span style="color: #ff7700;font-weight:bold;">in</span> <span style="color: #dc143c;">sys</span>.<span style="color: black;">builtin_module_names</span> \
        <span style="color: #ff7700;font-weight:bold;">or</span> <span style="color: #ff7700;font-weight:bold;">not</span> <span style="color: #008000;">hasattr</span><span style="color: black;">&#40;</span>attrModule<span style="color: #66cc66;">,</span> <span style="color: #483d8b;">'__file__'</span><span style="color: black;">&#41;</span> \
        <span style="color: #ff7700;font-weight:bold;">or</span> attrModule <span style="color: #66cc66;">==</span> <span style="color: #dc143c;">sys</span>.<span style="color: black;">modules</span><span style="color: black;">&#91;</span>__name__<span style="color: black;">&#93;</span>:
            <span style="color: #ff7700;font-weight:bold;">continue</span>
&nbsp;
        <span style="color: #808080; font-style: italic;">#we also do not want to reload if the module comes from the standard lib</span>
        <span style="color: #808080; font-style: italic;">#to check for this, we need to get the module's path and check that it</span>
        <span style="color: #808080; font-style: italic;">#is in the lib folder, but not in the site packages folder</span>
        moduleFilepath <span style="color: #66cc66;">=</span> attrModule.__file__.<span style="color: black;">lower</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
        pyStdLib <span style="color: #66cc66;">=</span> sysconfig.<span style="color: black;">get_python_lib</span><span style="color: black;">&#40;</span>standard_lib<span style="color: #66cc66;">=</span><span style="color: #008000;">True</span><span style="color: black;">&#41;</span>.<span style="color: black;">lower</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
        pySitePkg <span style="color: #66cc66;">=</span> sysconfig.<span style="color: black;">get_python_lib</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>.<span style="color: black;">lower</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
&nbsp;
        <span style="color: #ff7700;font-weight:bold;">if</span> moduleFilepath.<span style="color: black;">startswith</span><span style="color: black;">&#40;</span>pyStdLib<span style="color: black;">&#41;</span> \
        <span style="color: #ff7700;font-weight:bold;">and</span> <span style="color: #ff7700;font-weight:bold;">not</span> moduleFilepath.<span style="color: black;">startswith</span><span style="color: black;">&#40;</span>pySitePkg<span style="color: black;">&#41;</span>:
            <span style="color: #ff7700;font-weight:bold;">continue</span>
&nbsp;
        <span style="color: #808080; font-style: italic;">#add the module to the list of modules that have been imported</span>
        detectedModules.<span style="color: black;">add</span><span style="color: black;">&#40;</span>attrModule<span style="color: black;">&#41;</span>
&nbsp;
        <span style="color: #808080; font-style: italic;">#if the attr value does not have a name attr, skip to the next iteration</span>
        <span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: #ff7700;font-weight:bold;">not</span> <span style="color: #008000;">hasattr</span><span style="color: black;">&#40;</span>attrVal<span style="color: #66cc66;">,</span> <span style="color: #483d8b;">'__name__'</span><span style="color: black;">&#41;</span>:
            <span style="color: #ff7700;font-weight:bold;">continue</span>
&nbsp;
        <span style="color: #808080; font-style: italic;">#if the module where the attr value came from is different from the</span>
        <span style="color: #808080; font-style: italic;">#current module, collect data we need to remap things</span>
        origName <span style="color: #66cc66;">=</span> attrVal.__name__
        <span style="color: #ff7700;font-weight:bold;">if</span> attrModule <span style="color: #66cc66;">!=</span> module:
            <span style="color: #808080; font-style: italic;">#print module.__name__, attrName, attrModule.__name__, origName</span>
            remapData <span style="color: #66cc66;">=</span> ImportRemapData<span style="color: black;">&#40;</span>
                module.__name__<span style="color: #66cc66;">,</span>
                attrName<span style="color: #66cc66;">,</span>
                attrModule.__name__<span style="color: #66cc66;">,</span>
                origName<span style="color: #66cc66;">,</span>
                <span style="color: #008000;">type</span><span style="color: black;">&#40;</span>attrVal<span style="color: black;">&#41;</span>
                <span style="color: black;">&#41;</span>
            _remappingData.<span style="color: black;">append</span><span style="color: black;">&#40;</span>remapData<span style="color: black;">&#41;</span>
&nbsp;
    <span style="color: #808080; font-style: italic;">#add the detected modules to the imported modules set</span>
    _importedModules.<span style="color: black;">update</span><span style="color: black;">&#40;</span>detectedModules<span style="color: black;">&#41;</span>
&nbsp;
    <span style="color: #808080; font-style: italic;">#cycle through the modules we detected, which have not already been processed</span>
    <span style="color: #808080; font-style: italic;">#and process them as well</span>
    <span style="color: #ff7700;font-weight:bold;">for</span> detectedModule <span style="color: #ff7700;font-weight:bold;">in</span> detectedModules:
&nbsp;
        <span style="color: #ff7700;font-weight:bold;">if</span> detectedModule <span style="color: #ff7700;font-weight:bold;">in</span> _processedModules:
            <span style="color: #ff7700;font-weight:bold;">continue</span>
&nbsp;
        _getModuleData<span style="color: black;">&#40;</span>detectedModule<span style="color: black;">&#41;</span>
&nbsp;
    <span style="color: #ff7700;font-weight:bold;">return</span> <span style="color: #008000;">True</span></pre></td></tr></table></div>

<p>The recursiveReload method within the module is what is of interest here. To use this script, simply pass a module to this method. It will collect all modules that have been imported into the current working module, as well as all classes and modules that have been imported from modules or imported using aliases. It will then search each of the collected sub modules for the same information, and so on and so forth. When it hits the bottom, it will finish searching and then begin the reloading process. It will reload all of the modules, and then re-map extra data such as methods and classes and aliases.</p>
<p>Here is an example of the script in action. Save the following sample scripts in the same directory as the recursiveReload.py module seen above. Run test1a.py and then go and edit and save the test2.py and test3.py files while test1a.py is still running. Not everything will properly reload. Now, do the same with test1b.py. All changes should reload.</p>
<p>test1a.py:</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="python" style="font-family:monospace;"><span style="color: #ff7700;font-weight:bold;">import</span> test2
&nbsp;
<span style="color: #ff7700;font-weight:bold;">from</span> <span style="color: #dc143c;">time</span> <span style="color: #ff7700;font-weight:bold;">import</span> sleep
&nbsp;
<span style="color: #ff7700;font-weight:bold;">while</span> <span style="color: #008000;">True</span>:
    <span style="color: #ff7700;font-weight:bold;">print</span> <span style="color: #483d8b;">'This is test1a.py'</span>
    <span style="color: #008000;">reload</span><span style="color: black;">&#40;</span>test2<span style="color: black;">&#41;</span>
    test2.<span style="color: black;">printStatement</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
    sleep<span style="color: black;">&#40;</span><span style="color: #ff4500;">5</span><span style="color: black;">&#41;</span></pre></td></tr></table></div>

<p>test1b.py:</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="python" style="font-family:monospace;"><span style="color: #ff7700;font-weight:bold;">import</span> <span style="color: #dc143c;">sys</span>
<span style="color: #ff7700;font-weight:bold;">import</span> test2
&nbsp;
<span style="color: #ff7700;font-weight:bold;">from</span> <span style="color: #dc143c;">time</span> <span style="color: #ff7700;font-weight:bold;">import</span> sleep
<span style="color: #ff7700;font-weight:bold;">from</span> recursiveReload <span style="color: #ff7700;font-weight:bold;">import</span> recursiveReload
&nbsp;
<span style="color: #ff7700;font-weight:bold;">while</span> <span style="color: #008000;">True</span>:
    <span style="color: #ff7700;font-weight:bold;">print</span> <span style="color: #483d8b;">'This is test1b.py'</span>
    thisModule <span style="color: #66cc66;">=</span> <span style="color: #dc143c;">sys</span>.<span style="color: black;">modules</span><span style="color: black;">&#91;</span>__name__<span style="color: black;">&#93;</span>
    recursiveReload<span style="color: black;">&#40;</span>thisModule<span style="color: #66cc66;">,</span> debug<span style="color: #66cc66;">=</span><span style="color: #008000;">True</span><span style="color: black;">&#41;</span>
    test2.<span style="color: black;">printStatement</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
    sleep<span style="color: black;">&#40;</span><span style="color: #ff4500;">5</span><span style="color: black;">&#41;</span></pre></td></tr></table></div>

<p>test2.py:</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="python" style="font-family:monospace;"><span style="color: #ff7700;font-weight:bold;">from</span> test3 <span style="color: #ff7700;font-weight:bold;">import</span> anotherPrintStatement
<span style="color: #ff7700;font-weight:bold;">from</span> test3 <span style="color: #ff7700;font-weight:bold;">import</span> PrintMultiplication <span style="color: #ff7700;font-weight:bold;">as</span> PrintMulti
&nbsp;
<span style="color: #ff7700;font-weight:bold;">def</span> printStatement<span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>:
    <span style="color: #ff7700;font-weight:bold;">print</span> <span style="color: #483d8b;">'This is test2.py'</span>
    anotherPrintStatement<span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
    PrintMulti<span style="color: black;">&#40;</span><span style="color: #ff4500;">1</span><span style="color: #66cc66;">,</span> <span style="color: #ff4500;">2</span><span style="color: black;">&#41;</span></pre></td></tr></table></div>

<p>test3.py:</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="python" style="font-family:monospace;"><span style="color: #ff7700;font-weight:bold;">def</span> anotherPrintStatement<span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>:
    <span style="color: #ff7700;font-weight:bold;">print</span> <span style="color: #483d8b;">'This is test3.py'</span>
&nbsp;
<span style="color: #ff7700;font-weight:bold;">class</span> PrintMultiplication<span style="color: black;">&#40;</span><span style="color: #008000;">object</span><span style="color: black;">&#41;</span>:
    <span style="color: #ff7700;font-weight:bold;">def</span> <span style="color: #0000cd;">__init__</span><span style="color: black;">&#40;</span><span style="color: #008000;">self</span><span style="color: #66cc66;">,</span> x<span style="color: #66cc66;">,</span> y<span style="color: black;">&#41;</span>:
        <span style="color: #ff7700;font-weight:bold;">print</span> x * y</pre></td></tr></table></div>

<p>Feel free to continue adding more modules and make the importation chain even longer. It should continue to work.</p>
<p>You can pass True to the optional argument <em>debug</em> to have information printed to the console about which modules are being reloaded. The method will not reload builtin modules, the recursiveReload module, the __main__ module (it qualifies as a builtin anyways), and any modules that originate from the Python installation&#8217;s standard library but not in the site packages.</p>
<p>There are a few situations where this module currently will not work. It will fail when importing variables from other modules that are storing basic data types such as strings, ints, floats, booleans. They cannot be traced back to the module where they originated from using the inspect.getmodule method.</p>
<p>This will also fail if you change an import statement from <em>from moduleName import moduleName</em> to <em>import moduleName</em>, if moduleName is the name of the module and then name of an object from within the module that you are importing. I have yet to get this change properly remapping. You can, however, change an import statement from <em>from moduleName import methodName </em>to <em>import moduleName</em> with no issues.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.mathiesonfacer.com/tools/maya/python-module-recursivereload/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Separate blendshapes seamlessly in Maya</title>
		<link>http://www.mathiesonfacer.com/featured/separate-blendshapes-seamlessly-in-maya/</link>
		<comments>http://www.mathiesonfacer.com/featured/separate-blendshapes-seamlessly-in-maya/#comments</comments>
		<pubDate>Sat, 29 Oct 2011 21:54:03 +0000</pubDate>
		<dc:creator>Mat</dc:creator>
				<category><![CDATA[Featured]]></category>
		<category><![CDATA[Tutorials]]></category>

		<guid isPermaLink="false">http://www.mathiesonfacer.com/?p=1264</guid>
		<description><![CDATA[Last week, I had to come up with a way of separating one blendshape into multiple blendshapes. So basically, imagine we have one blendshape of a full smile and we need to separate it into left and right. If you go to the Edit Deformers menu, there is an option to paint blendshape weights. This [...]]]></description>
				<content:encoded><![CDATA[<p>Last week, I had to come up with a way of separating one blendshape into multiple blendshapes. So basically, imagine we have one blendshape of a full smile and we need to separate it into left and right.</p>
<p>If you go to the Edit Deformers menu, there is an option to paint blendshape weights. This is the tool we will be using, but the tricky part of separating blendshapes like this is the overlap area between the shapes. Since blendshapes are additive, if the overlap area is not done properly, when both blendshapes are enabled you may run into areas where it is morphing more or less than what you intended.</p>
<p><span id="more-1264"></span></p>
<p>So, our issue is essentially that these weights are not normalized. There is a simple solution to this problem: paint the weights using a skin node so that they are normalized, and then transfer the weights over to our blendshape node.</p>
<p>To do this, you will need to have good UVs set up for your mesh. They don&#8217;t have to be perfect, but they definitely cannot have any faces overlapping. When the UVs are good to go, duplicate your mesh. This is the mesh we will add the skin node to.</p>
<p>For our example, we are separating our main blendshape into left and right blendshapes. Create two joints and name them &#8220;left_blendshape&#8221; and &#8220;right_blendshape&#8221;. It doesn&#8217;t matter where you place these joints, as we are not going to be using them to deform the mesh. All we care about is getting the weights. Select these two joints and your skinning mesh and then create a smooth bind skin node. Paint your weights for however you want the shapes to be separated. The weights will be normalized so that all influences combined will add up to 1, which means our blendshapes will also add up to 1.</p>
<p>To transfer the weights over to your blendshape, select your skinned mesh and go to Skin &gt; Edit Smooth Skin &gt; Export Skin Weight Maps. Click on the options box. We want to export the luminance. Increase the map size to something large so get as much data transferred as possible. I use 2048&#215;2048. Choose TIFF as the file format. Export the maps to wherever you want, just as long as you remember where you saved them to.</p>
<p>Now, on your mesh that has the blendshape set up, so to Edit Deformers &gt; Paint Blend Shape Weights Tool. Click on the options box to bring up the tools panel. Select your main blendshape that your are wanting to separate into left and right shapes. Go down to Attribute Maps &gt; Import. Make sure Luminance is chosen for Import value and then click on the Import button. Navigate to the folder where you exported your weight maps to from the skin node. Load the &#8220;left_blendshape&#8221; map and when you set the weight for the main blendshape to 1, it should only enable the blendshape on the left side. Duplicate the mesh, and you now have your blendshape for the left side. Repeat this process to get your right side blendshape as well.</p>
<p>Now that you have both your right and left blendshapes as separate meshes, select them both, select your main, undeformed mesh, and create a new blendshape node. The new blendshape node should now have both your left and right side blendshapes, and if you set both of their weights to 1 in the channel box they should add together perfectly and look exactly like the main blendshape that you started the process with.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.mathiesonfacer.com/featured/separate-blendshapes-seamlessly-in-maya/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Rig encapsulation using Maya&#8217;s assets</title>
		<link>http://www.mathiesonfacer.com/blog/rig-encapsulation-using-mayas-assets/</link>
		<comments>http://www.mathiesonfacer.com/blog/rig-encapsulation-using-mayas-assets/#comments</comments>
		<pubDate>Sun, 04 Sep 2011 04:10:51 +0000</pubDate>
		<dc:creator>Mat</dc:creator>
				<category><![CDATA[Blog]]></category>

		<guid isPermaLink="false">http://www.mathiesonfacer.com/?p=1257</guid>
		<description><![CDATA[I&#8217;ve been playing around lately with Maya&#8217;s assets, and I think they&#8217;re pretty cool. Following the example provided in Maya&#8217;s documents, I wasn&#8217;t too happy with the result. I had to play around a bit before figuring out how I want to use them. Here are my thoughts on some points after playing around. There [...]]]></description>
				<content:encoded><![CDATA[<p>I&#8217;ve been playing around lately with Maya&#8217;s assets, and I think they&#8217;re pretty cool. Following the example provided in Maya&#8217;s documents, I wasn&#8217;t too happy with the result. I had to play around a bit before figuring out how I want to use them. Here are my thoughts on some points after playing around.</p>
<p>There are two levels of encapsulation when working with assets: black boxing and attribute locking. Black boxing basically just hides  any non-published nodes from the Outliner so the animators can&#8217;t go getting into trouble with the guts of the rig. The guts of the rig is the proverbial &#8220;big red button&#8221;: leave a note saying &#8220;DO NOT TOUCH&#8221;, and it only increases temptation. Attribute locking goes through the entire asset and locks any attributes that have not been published.</p>
<p><span id="more-1257"></span></p>
<p>There are a few problems with both of these encapsulation types. The biggest problems I have belong to the attribute locking. First off, any attributes you do not publish for the animator to use get locked and hidden. This means that for any attribute you want the animator to use, you actually need to publish. The problem with this is that every published attribute gets added to the asset node. This is a very useful feature, as you can publish your geometry visibility and controls visibility toggles, for example, and have them appear on the master node of the encapsulated rig, but when you have a hundred or so controls in the rig and several attributes per control that need to be published&#8230; well, yeah, it becomes cluttered and messy. All of a sudden a great feature has become completely useless.</p>
<p>Second problem with attribute locking is, locking certain attributes on certain nodes can actually break your rig. I wrote a MEL script on a previous production that was to go through all hidden nodes and lock all attributes on those nodes. I found that after doing this it would actually kill my IK handles and/or constraints (I didn&#8217;t bother trying to troubleshoot it much since it was obviously having major issues, so not sure exactly which nodes and attributes were having the problem). I thought Autodesk would have been taken into consideration with Maya&#8217;s assets, but apparently not. I ran into the same issue where parts of my rig just straight up broke after locking attributes.</p>
<p>The problem with black boxing, luckily, is a very small problem which can be easily fixed. The problem is that, although unpublished nodes are hidden from the Outliner, the animators can still select them when doing a select hierarchy command, so they&#8217;re not actually fully &#8220;black-boxed&#8221;. I fixed this by setting up two script jobs. The first script job is for when a scene is loaded. When the scene is loaded, it collects all asset container nodes, cycles through them, and appends the names of all unpublished nodes in each asset container to a shared array. The other script job is for whenever a new selection is made. When a new selection is made, the script job just quickly deselects the list of unpublished nodes we collected earlier.</p>
<p>One other issue I&#8217;ve run into is that when you add nodes to an asset, it essentially makes it impossible to work with it in the hypergraph. All of the nodes are stored in a container, and there is no isolating the nodes. If you select one node and tell it to graph just one level deep for inputs and outputs, it ignores you. You are looking at the entire node graph at all times, whether you like it or not. For this reason, I&#8217;ve actually made this entire process automated, and it is performed when the rig gets published. The script assumes you are organizing your rig scene a certain way, and then packages the rig accordingly. To explain further, when I start creating a rig, I have a hierarchy of group nodes set up that looks similar to the following:</p>
<ul>
<li>master</li>
<ul>
<li>controls</li>
<li>geo</li>
<ul>
<li>highRes</li>
<li>lowRes</li>
</ul>
<li>rig</li>
<ul>
<li>joints</li>
<li>deformers</li>
<li>misc</li>
</ul>
</ul>
</ul>
<p>The packaging script knows to expect these nodes. It collects all nodes under the master node and adds them into an asset. Then, it collects all nodes under controls prefixed with &#8220;CNT_&#8221; and publishes them so they will still appear in the Outliner when blackboxed. Once blackboxed, the &#8220;CNT_&#8221; prefix is kind of redundant since every single node you see will have &#8220;CNT_&#8221; in front. I like to remove the prefix during packaging so that the animator only sees &#8220;LeftArm&#8221; or &#8220;Neck&#8221;, for example. It makes the rig a lot more readable in the Outliner.</p>
<p>Also, the packager expects that all attributes found on the master node found above should be published to the asset. Although I am not using the Lock Attribute feature, publishing attributes still makes it so that those attributes appear on the asset node. There is a setting in the channel box that allows you to have these attributes then be visible whenever you have selected any object belonging to the asset. This can be nice as long as you keep the number of attributes low and they are something that affects the entire rig.</p>
<p>Oh, I almost forgot one other cool thing about using assets. It makes walking the hierarchy a sinch for animators. The up and down arrows do not take you to the shape node, or the group node you have your control parented to. It takes you directly to the next published node and skips everything else in between.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.mathiesonfacer.com/blog/rig-encapsulation-using-mayas-assets/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Final Destination 5</title>
		<link>http://www.mathiesonfacer.com/blog/final-destination-5/</link>
		<comments>http://www.mathiesonfacer.com/blog/final-destination-5/#comments</comments>
		<pubDate>Sun, 21 Aug 2011 00:57:38 +0000</pubDate>
		<dc:creator>Mat</dc:creator>
				<category><![CDATA[Blog]]></category>

		<guid isPermaLink="false">http://www.mathiesonfacer.com/blog/final-destination-5/</guid>
		<description><![CDATA[A movie I recently worked on came out last weekend. That movie is Final Destination 5. I worked on it over at Prime Focus from February to the end of June. Prime Focus was responsible for the epic bridge collapse sequence in the movie. A lot of hard work went into the sequence, and it [...]]]></description>
				<content:encoded><![CDATA[<p><a href="http://www.mathiesonfacer.com/wp-content/images/galleryImages/292236_10150758645530445_840485444_20344659_4069721_n.jpg"><img class="size-full wp-image-1252 alignleft" title="292236_10150758645530445_840485444_20344659_4069721_n" src="http://www.mathiesonfacer.com/wp-content/images/galleryImages/292236_10150758645530445_840485444_20344659_4069721_n.jpg" alt="" width="128" height="384" /></a>A movie I recently worked on came out last weekend. That movie is Final Destination 5. I worked on it over at Prime Focus from February to the end of June.</p>
<p>Prime Focus was responsible for the epic bridge collapse sequence in the movie. A lot of hard work went into the sequence, and it featured a lot of gory deaths :)</p>
<p>I was responsible for the digital doubles on the bridge, both background and hero characters. I also wrote some tools for the project including a motion capture importer/mapper, and a tool to help match move easily make adjustments along the camera&#8217;s axis, while not changing how it appears to the camera, when stereoscope issues arose.</p>
<p>If you haven&#8217;t seen the movie yet, consider checking it out. You pretty much know what you&#8217;re going to get from a Final Destination movie, but this installation is a lot of fun, not as predictable with how the deaths play out, and quite funny!</p>
<p><span id="more-1251"></span></p>
]]></content:encoded>
			<wfw:commentRss>http://www.mathiesonfacer.com/blog/final-destination-5/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Intro to Maya Muscle</title>
		<link>http://www.mathiesonfacer.com/blog/intro-to-maya-muscle/</link>
		<comments>http://www.mathiesonfacer.com/blog/intro-to-maya-muscle/#comments</comments>
		<pubDate>Mon, 08 Aug 2011 06:22:47 +0000</pubDate>
		<dc:creator>Mat</dc:creator>
				<category><![CDATA[Blog]]></category>

		<guid isPermaLink="false">http://www.mathiesonfacer.com/?p=1247</guid>
		<description><![CDATA[I started using Maya Muscle this past week for a project I am doing at work. I&#8217;m enjoying it a lot so far. Muscle simulations have come a long way since I was last actively working with them. I started out using the simple muscle system with the muscle spline deformer, but at the advice [...]]]></description>
				<content:encoded><![CDATA[<p>I started using Maya Muscle this past week for a project I am doing at work. I&#8217;m enjoying it a lot so far. Muscle simulations have come a long way since I was last actively working with them.</p>
<p>I started out using the simple muscle system with the muscle spline deformer, but at the advice of the documentation I have started exploring the newer &#8220;Muscle Creator&#8221; system, successor to the &#8220;Muscle Builder&#8221;. I can see how this new system adds more flexibility and makes things even easier again for setting up and customizing muscles (as stated in the docs).</p>
<p><span id="more-1247"></span></p>
<p>I am going to continue testing both methods for the time being though. I&#8217;d like to decide for myself which workflow I think works best rather than just following what the documentation tells me to do. There have been many &#8220;new and improved&#8221; features rolled out in software packages in the past few years which never really caught on. Some do succeed admirably, but it seems just as many end up failing. Best thing to do, usually, is listen to general consensus among peers. So far in my searching, however, I have yet to find a consensus out there. Going to have to figure it out on my own.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.mathiesonfacer.com/blog/intro-to-maya-muscle/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Nesquik Commercials</title>
		<link>http://www.mathiesonfacer.com/featured/nesquik-commercials/</link>
		<comments>http://www.mathiesonfacer.com/featured/nesquik-commercials/#comments</comments>
		<pubDate>Sat, 06 Aug 2011 04:18:27 +0000</pubDate>
		<dc:creator>Mat</dc:creator>
				<category><![CDATA[Featured]]></category>
		<category><![CDATA[Projects]]></category>
		<category><![CDATA[Work]]></category>

		<guid isPermaLink="false">http://www.mathiesonfacer.com/?p=1238</guid>
		<description><![CDATA[This is another project I did almost two years ago now. Once again, it was a quick turnaround for Hatch Studio, when I was last working at PEN Productions. Paul Neale Rigged the ears on the bunny in the two commercial spots the bunny character was used in, while I took care of the rest [...]]]></description>
				<content:encoded><![CDATA[<p style="text-align: center;"><a href="http://www.mathiesonfacer.com/wp-content/images/galleryImages/nesquik.jpg"><img class="aligncenter size-full wp-image-1239" title="nesquik" src="http://www.mathiesonfacer.com/wp-content/images/galleryImages/nesquik.jpg" alt="" width="546" height="410" /></a></p>
<p style="text-align: left;">This is another project I did almost two years ago now. Once again, it was a quick turnaround for Hatch Studio, when I was last working at PEN Productions. Paul Neale Rigged the ears on the bunny in the two commercial spots the bunny character was used in, while I took care of the rest of the character. I think Hatch did a great job on these commercials, as well as the Kid&#8217;s Cuisine spots.</p>
<p><span id="more-1238"></span></p>
<p style="text-align: left;"><a href="http://www.hatchstudios.net/#index.cfm?event=display.work&amp;workid=148" target="_blank">Click here to head over to Hatch Studio&#8217;s website and watch the ads.</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.mathiesonfacer.com/featured/nesquik-commercials/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
