<?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>duber's blog &#187; Maya</title>
	<atom:link href="http://blog.duber.cz/category/maya/feed" rel="self" type="application/rss+xml" />
	<link>http://blog.duber.cz</link>
	<description>the official duber studio™ blog</description>
	<lastBuildDate>Thu, 22 Jul 2010 15:53:28 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.1</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Autodesk announces their 2010 product line</title>
		<link>http://blog.duber.cz/3ds-max/autodesk-announces-their-2010-product-line</link>
		<comments>http://blog.duber.cz/3ds-max/autodesk-announces-their-2010-product-line#comments</comments>
		<pubDate>Tue, 04 Aug 2009 02:43:27 +0000</pubDate>
		<dc:creator>loocas</dc:creator>
				<category><![CDATA[3ds Max]]></category>
		<category><![CDATA[Maya]]></category>
		<category><![CDATA[opinions]]></category>
		<category><![CDATA[software]]></category>
		<category><![CDATA[2010]]></category>
		<category><![CDATA[3ds]]></category>
		<category><![CDATA[announce]]></category>
		<category><![CDATA[announcement]]></category>
		<category><![CDATA[Autodesk]]></category>
		<category><![CDATA[composite]]></category>
		<category><![CDATA[features]]></category>
		<category><![CDATA[match]]></category>
		<category><![CDATA[matchmover]]></category>
		<category><![CDATA[Max]]></category>
		<category><![CDATA[mover]]></category>
		<category><![CDATA[new]]></category>
		<category><![CDATA[siggraph]]></category>
		<category><![CDATA[Softimage]]></category>
		<category><![CDATA[suite]]></category>
		<category><![CDATA[suites]]></category>
		<category><![CDATA[toxik]]></category>
		<category><![CDATA[tracking]]></category>
		<category><![CDATA[XSI]]></category>

		<guid isPermaLink="false">http://blog.duber.cz/3ds-max/autodesk-announces-their-2010-product-line</guid>
		<description><![CDATA[Following the announcement, Autodesk revealed the 2010 product line.
Hands down, the updates are really not about new big features at all, this time. Well, maybe except for Maya 2010, which&#8217;ll, for the first time in years, come in one version only, just Maya 2010, no Unlimited or Complete (which was confusing anyways) and will include [...]]]></description>
			<content:encoded><![CDATA[<p>Following <a href="http://area.autodesk.com/blogs/cory/maya_and_motionbuilder_2010_announcement">the announcement</a>, Autodesk revealed the 2010 product line.</p>
<p>Hands down, the updates are really not about new big features at all, this time. Well, maybe except for <a href="http://usa.autodesk.com/adsk/servlet/pc/index?siteID=123112&#038;id=13583239#channels_What%27s%20New">Maya 2010</a>, which&#8217;ll, for the first time in years, come in one version only, just Maya 2010, no Unlimited or Complete (which was confusing anyways) and will include Toxik (altough called Maya Composite) and MatchMover.</p>
<p>I still haven&#8217;t seen any presentations of these new features, but I&#8217;m really looking forward to that. Even though I really dislike the idea of having Toxik inside of Maya by default. I never liked that compositor, always felt very &#8220;Flame-ish&#8221; and therefore &#8220;odd&#8221; to me, being used to Fusion or Nuke. But still, I&#8217;ll save my judgement after I see a demo.</p>
<p>Autodesk also announced a <a href="http://usa.autodesk.com/adsk/servlet/pc/index?siteID=123112&#038;id=13567426">3ds Max 2010 SP1</a> release, which is always good<del datetime="2009-08-04T13:32:15+00:00">, if it wasn&#8217;t for &#8220;subscribtion customers only&#8221;, which is, in my opinion, bullshit!</del></p>
<p>Then <a href="http://usa.autodesk.com/adsk/servlet/pc/index?siteID=123112&#038;id=13571400">Softimage 2010</a> with some minor additions and bugfixes. Notably f-curve editor really needed that sweet touch and Scintilla, which I really felt in love with after it was included in 3ds Max, is also a very nice additon.</p>
<p>They&#8217;ve also announced <a href="http://usa.autodesk.com/adsk/servlet/index?siteID=123112&#038;id=13420613">digital production Suites</a>, which seem to be a great idea, possibly taken from Adobe, that you&#8217;ll be able to buy a bundle of <a href="http://usa.autodesk.com/adsk/servlet/index?siteID=123112&#038;id=13441435">3ds Max/Maya, Motion Builder</a>, or even <a href="http://usa.autodesk.com/adsk/servlet/index?siteID=123112&#038;id=13420613">3ds Max/Maya, Motion Builder, Mudbox</a>. If the prices are &#8220;reasonable&#8221;, I&#8217;m sold!</p>
<p>As I&#8217;ve said, I&#8217;ll wait for tomorrow&#8217;s demos to pass my judgement on these new releases, so, stay tuned&#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.duber.cz/3ds-max/autodesk-announces-their-2010-product-line/feed</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>dotNET sweetness for Maya</title>
		<link>http://blog.duber.cz/maya/dotnet-sweetness-for-maya</link>
		<comments>http://blog.duber.cz/maya/dotnet-sweetness-for-maya#comments</comments>
		<pubDate>Thu, 11 Sep 2008 12:05:37 +0000</pubDate>
		<dc:creator>loocas</dc:creator>
				<category><![CDATA[Maya]]></category>
		<category><![CDATA[Python]]></category>
		<category><![CDATA[technical]]></category>
		<category><![CDATA[.NET]]></category>
		<category><![CDATA[develop]]></category>
		<category><![CDATA[dotNET]]></category>
		<category><![CDATA[framework]]></category>
		<category><![CDATA[GUI]]></category>
		<category><![CDATA[IronPython]]></category>
		<category><![CDATA[PythonNet]]></category>
		<category><![CDATA[run]]></category>
		<category><![CDATA[under]]></category>

		<guid isPermaLink="false">http://blog.duber.cz/maya/dotnet-sweetness-for-maya</guid>
		<description><![CDATA[
When I first started developing some tools, to speed up and aid our pipeline, in Maya I was furious to find out about Maya&#8217;s implemented GUI tools and methods. It was extremely unintuitive, very badly documented (especially regarding examples of the given object etc&#8230;) and heavily limiting. What I&#8217;d love to have in Maya was [...]]]></description>
			<content:encoded><![CDATA[<p><img src='http://blog.duber.cz/wp-content/uploads/maya_dotnet_banner.png' alt='maya_dotnet_banner' /></p>
<p>When I first started developing some tools, to speed up and aid our pipeline, in Maya I was furious to find out about Maya&#8217;s implemented GUI tools and methods. It was extremely unintuitive, very badly documented (especially regarding examples of the given object etc&#8230;) and heavily limiting. What I&#8217;d love to have in Maya was something similar to Max&#8217;s GUI objects I was used to.</p>
<p><span id="more-93"></span></p>
<p>Especially ever since Max 9, where we finally gained access to the beautiful dotNET framework and its objects, classes etc. I was looking for a similar solution. The only problem with dotNET is its platform dependence. As it&#8217;s a Microsoft framework it, obviously, only works on Windows. I&#8217;ve heard about Mono for Linux, but since I don&#8217;t work on Linux and have very limited knowledge of it, I didn&#8217;t investigate any further. There are some other options for platform-independent GUI development, like <a href="http://trolltech.com/products/qt/">Qt</a>, which I&#8217;m yet to go through. It&#8217;s definitely worth looking into, but the great advantage of dotNET, on the other hand, is its presence on virtually any Windows machine, which is simply awesome for heavy tools deployment across multiple machines in a studio environment (I can&#8217;t imagine making all our artists to install Qt). So, the obvious step was to look for a way to get dotNET run under Maya.</p>
<p>After searching the net, I quickly realized it won&#8217;t be such a simple task as with many other tools I&#8217;ve ported to Maya in the form of modules for Python. There is IronPython, which runs under its own interpreter, which makes it impossible to implement in Maya (very sad!), but then I bumped into a project, which seems to be lacking a bit of active development, but looked promising: <a href="http://pythonnet.sourceforge.net/">PythonNet</a>.</p>
<p>There&#8217;s a little bit of a glitch. There&#8217;s no x64 port and, what&#8217;s more irritating, the release version I managed to run under Maya only supports dotNET 1.1, which is a real pitty as the tools you&#8217;ll be able to create will have slightly limited functionality for more advanced tools development, but nothing that&#8217;d cripple the actual usefulness and richness of the platform, only some more advanced and newly added classes or methods won&#8217;t be supported.</p>
<p>An example of the dotNET&#8217;s listView object used under Maya:<br />
<img src='http://blog.duber.cz/wp-content/uploads/dotnet_lv_maya.png' alt='dotNET_listView_in_maya'/></p>
<p>So, all you need is to download the <a href="http://sourceforge.net/project/showfiles.php?group_id=162464&#038;package_id=183296">PythonNet 1.0 RC2 for dotNET 1.1</a> and install CLR.dll and Python.Runtime.dll in Maya&#8217;s bin folder. Done. From there on, you&#8217;ll be able to import a CLR module (note the upper-case) and access the dotNET objects and namespaces through it. There are also some nice examples of code to get you going.</p>
<p>Another dotNET example of an actual simple tool I developed for automatic Point Cache assignments:<br />
<img src='http://blog.duber.cz/wp-content/uploads/pcs_agent_maya.png' alt='point_caches_agent' /></p>
<p>Here, again, Python really excells in these matters. I&#8217;m able to develop a fairly complex GUI for my tools and then instance, inherit and mainly overflow the operators of the GUI, so, in the end, I can plot the same GUI for many various functions, which is very useful.</p>
<p>Right now I&#8217;m looking into some ways of getting the alpha verision of PythonNet 2.0, which supports dotNET 2.0 objects, to run under Maya in both x86 and x64 modes. If I get it going, I&#8217;ll post the way as well as the compiled modules (as I feel it&#8217;ll be necessary).</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.duber.cz/maya/dotnet-sweetness-for-maya/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Connecting to a MySQL database from CG applications.</title>
		<link>http://blog.duber.cz/3ds-max/connecting-to-a-mysql-database-from-cg-applications</link>
		<comments>http://blog.duber.cz/3ds-max/connecting-to-a-mysql-database-from-cg-applications#comments</comments>
		<pubDate>Sat, 09 Aug 2008 22:19:19 +0000</pubDate>
		<dc:creator>loocas</dc:creator>
				<category><![CDATA[3ds Max]]></category>
		<category><![CDATA[Maya]]></category>
		<category><![CDATA[Python]]></category>
		<category><![CDATA[maxscript]]></category>
		<category><![CDATA[technical]]></category>
		<category><![CDATA[.NET]]></category>
		<category><![CDATA[3d]]></category>
		<category><![CDATA[3ds]]></category>
		<category><![CDATA[accessing]]></category>
		<category><![CDATA[assembly]]></category>
		<category><![CDATA[connecting]]></category>
		<category><![CDATA[connection]]></category>
		<category><![CDATA[connector]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[dotNET]]></category>
		<category><![CDATA[Max]]></category>
		<category><![CDATA[ODBC]]></category>
		<category><![CDATA[string]]></category>
		<category><![CDATA[using]]></category>

		<guid isPermaLink="false">http://blog.duber.cz/3ds-max/connecting-to-a-mysql-database-from-cg-applications</guid>
		<description><![CDATA[I&#8217;ve been recently doing some R&#38;D on MySQL databases and connection through Python in Maya as well as Python in Max (through blurPython library), but I couldn&#8217;t seem to have found a way to connect to a MySQL database via ODBC. The problem lied in OLE methods as they&#8217;re not both much documented in MAXScript [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been recently doing some R&amp;D on MySQL databases and connection through Python in Maya as well as Python in Max (through blurPython library), but I couldn&#8217;t seem to have found a way to connect to a MySQL database via ODBC. The problem lied in OLE methods as they&#8217;re not both much documented in MAXScript reference and they&#8217;re tied to the operating system, not Max directly. But thankfully, I bumped into a solution today, out of a blue <img src='http://blog.duber.cz/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p><span id="more-54"></span></p>
<p>To save you some time, don&#8217;t bother trying to connect to the database (db for short) via the standard example:<br />
<code>DogConn=createOLEObject "ADODB.Connection"<br />
DogConn.Open "driver={SQL Server}; server=localhost; database=test"</code></p>
<p>output:<br />
<code><OLEObject:ADODB.connection><br />
-- Runtime error: OLEObject method call failed:<br />
Error Message 1: [Microsoft][ODBC SQL Server Driver][DBNETLIB]SQL Server does not exist or access denied.<br />
method: open()</code></p>
<p>This concrete driver is a Microsoft SQL Server driver, so obviously, this doesn&#8217;t make much senese to use this method for connecting to a MySQL database. Since there are numerous ways of setting up the connection via different providers or drivers I was lost. But thankfully , Sun provides its own <a href="http://dev.mysql.com/downloads/connector/odbc/5.1.html">ODBC connectors</a> for various operating systems, including 64bit versions for Windows. So download the one that fits your OS and after installing it, just check what name the driver has assigned in the Data Sources(ODBC) under Administrative Tools. It should read &#8220;MySQL ODBC 5.1 Driver&#8221;, which is exactly what you need for successful connecting to a MySQL database. Easily enough, from the comprehensive list of example connection strings found at <a href="http://www.connectionstrings.com/?carrier=mysql">ConnectionStrings.com</a> I was finally able to write this code:</p>
<p><code>DogConn=createOLEObject "ADODB.Connection"<br />
DogConn.Open "Driver={MySQL ODBC 5.1 Driver};Server=serverName;Database=dbName;User=userName; Password=password"</code></p>
<p>Even though it returns &#8220;undefined&#8221;, don&#8217;t be alarmed, this is a good thing. So, now you&#8217;re good to go and start fully appretiating the whole database purpose and design!</p>
<p>As for dotNET. It&#8217;s much easier (as it&#8217;s Microsoft&#8217;s next &#8220;big thing&#8221;) to code for and also you&#8217;re less likely to bump into similar problems. Again, download <a href="http://dev.mysql.com/downloads/connector/net/5.2.html">the latest .NET connector from Sun</a> and try executing this snippet in Max 9+:</p>
<p><code>dotNet.loadAssembly "C:\\Program Files (x86)\\MySQL\\MySQL Connector Net 5.2.2\\Binaries\\.NET 2.0\\MySql.Data.dll"<br />
DBConnection = dotNetObject "MySql.Data.MySqlClient.MySqlConnection"<br />
DBConnection.ConnectionString = "Server=192.168.1.14;Database=test;Uid=root;Pwd=root"<br />
DBConnection.open()</code></p>
<p>dotNET works in a slightly different way. Instead of loading up a provider or service, it loads up an &#8220;assembly&#8221;, which is a dll, in this case Sun&#8217;s .NET connector, and then allows you to work with its methods. So I first loaded the dll up, then fired the dotNetObject function, then I specified the connection string and finally opened up the connection. Then you&#8217;re good to go!</p>
<p>Even simplier is the Python way of things, as usual <img src='http://blog.duber.cz/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> All you need is a <a href="http://sourceforge.net/projects/mysql-python">MySQLdb module available at SourceForge.net</a>, install it for your version of Python and then try running this code:</p>
<p><code>import MySQLdb as db<br />
conn = db.connect("serverName","userName","password","databaseName")</code></p>
<p>Now you&#8217;re ready for some serious querying! <img src='http://blog.duber.cz/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> It really is this simple and that&#8217;s why <a href="http://blog.duber.cz/3ds-max/im-loving-python">I&#8217;m really loving Python</a>. Anyways, these were just a few examples of how to connect to a MySQL database via ODBC, .NET and Python, which is really all you&#8217;ll ever need for connecting to MySQL from 3ds Max, Maya or XSI.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.duber.cz/3ds-max/connecting-to-a-mysql-database-from-cg-applications/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Transform conversion successful!</title>
		<link>http://blog.duber.cz/3ds-max/transform-conversion-successful</link>
		<comments>http://blog.duber.cz/3ds-max/transform-conversion-successful#comments</comments>
		<pubDate>Wed, 25 Jun 2008 14:47:16 +0000</pubDate>
		<dc:creator>loocas</dc:creator>
				<category><![CDATA[3ds Max]]></category>
		<category><![CDATA[Maya]]></category>
		<category><![CDATA[technical]]></category>
		<category><![CDATA[3ds]]></category>
		<category><![CDATA[conversion]]></category>
		<category><![CDATA[matrix]]></category>
		<category><![CDATA[Max]]></category>
		<category><![CDATA[success]]></category>
		<category><![CDATA[successful]]></category>
		<category><![CDATA[transform]]></category>
		<category><![CDATA[transformation]]></category>
		<category><![CDATA[xform]]></category>

		<guid isPermaLink="false">http://blog.duber.cz/3ds-max/transform-conversion-successful</guid>
		<description><![CDATA[Just a quick note about my latest, successful  , transform conversion in a real production environment. If you&#8217;ve read my last article about the transformation matrices and how they can be used for manipulating object positions, rotations and scale, you&#8217;ll remember I also wrote about an example of converting 3ds Max object transform matrix [...]]]></description>
			<content:encoded><![CDATA[<p>Just a quick note about my latest, successful <img src='http://blog.duber.cz/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> , transform conversion in a real production environment. If you&#8217;ve read my last article about <a href="http://blog.duber.cz/3ds-max/the-transformation-matrix-is-useful-when-understood">the transformation matrices</a> and how they can be used for manipulating object positions, rotations and scale, you&#8217;ll remember I also wrote about an example of converting 3ds Max object transform matrix into Maya&#8217;s xform matrix. All I needed was some real-world scenarion where I could successfully test out this method as it was, to me, untested territory. It finally came on <a href="http://www.imdb.com/title/tt1041804/">the project</a> we&#8217;ve been working on at <a href="http://www.upp.cz">UPP</a>. I have several characters set-up and rigged in 3ds Max that I then transfer between various software packages we use here (mainly Maya and XSI). Obviously, the problem is the Up axis that is different in 3ds Max, which is the Z axis, in Maya and XSI it&#8217;s the Y axis. The problem isn&#8217;t the translation of objects, that&#8217;s easy, the main problem is the rotation of objects that needs to be converted to the different axis scheme.</p>
<p><a href='http://blog.duber.cz/wp-content/uploads/matrix_max_to_maya.png' title='Max_to_Maya_matrix_conversion' rel="lightbox[72]"><img src='http://blog.duber.cz/wp-content/uploads/matrix_max_to_maya.thumbnail.png' alt='Max to Maya matrix conversion' /></a></p>
<p><span id="more-72"></span></p>
<p>The concrete problem I had to solve was a prop, a motorcycle (an old, steampunk-like machine), that was already baked into individual point cache files. The prop is consisted of around 1000 pieces and baking the 400f animation takes about 1 hour. The problem was that a simplified version of the bike was animated in MotionBuilder, then the secondary animation was taken care of by my rig, which then gets baked and transferred over to Maya for rendering. Unfortunately when facing extreme deadlines, errors tend to happen. One such error happened from the animation side, the bike was offset in its <em>reference</em> node (if you&#8217;re familiar with MotionBuilder, you know this isn&#8217;t a good thing). The other thing is the point cache baking that drives its offset data from the parent, NOT from the world origin! Well, PointOven does that, but PC2 doesn&#8217;t. The final result was that in Max the bike was offset by a certain translation value and to make it even worse, it was slightly rotated. FBX transferred this offset correctly, but point cache data didn&#8217;t take the offset into account and calculated the vertex data from the <em>reference</em> position, which acts in the hierarchy as the <em>identity matrix</em> (matrix3 [1,0,0] [0,1,0] [0,0,1] [0,0,0]) = no offset.</p>
<p>A &#8220;safe&#8221; solution would be to re-cache the whole prop, which would be a waste of time, as I said, it takes around an hour to do, besides in the particular shot we worked on there were five motorcycles and five riders, which is a sh*t-load of data, if you ask me! So, instead of recaching the data, I identified the problem as a simple, stationary, matrix offset in 3ds Max. I wrote a function that coverted and formatted the 3ds Max matrix3 value into Maya matrix4 value and run a single line of code in Maya to offset the root of the prop with all the caches on.</p>
<p>All this took me about 5 minutes to do instead of an hour and something doing it the conventional way &#8211; fixing the error in MotionBuilder, replotting the animation, re-caching the meshes and then re-importing the newly created caches in Maya. Of course I fixed the error later, when I had the time, so that next time we don&#8217;t have to offset anything, but in a critical time, such a deadline is, this was the best solution I could have came up with. So, I consider my experimental matrix conversion method as proven and I&#8217;ll be looking forward to start fully utilizing this method in my future rigs/systems/tools as that&#8217;s a very powerful, yet simple way of bridging various 3ds apps together when it comes to animation data transfer.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.duber.cz/3ds-max/transform-conversion-successful/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>The transformation matrix is very useful, when understood.</title>
		<link>http://blog.duber.cz/3ds-max/the-transformation-matrix-is-useful-when-understood</link>
		<comments>http://blog.duber.cz/3ds-max/the-transformation-matrix-is-useful-when-understood#comments</comments>
		<pubDate>Mon, 02 Jun 2008 22:01:42 +0000</pubDate>
		<dc:creator>loocas</dc:creator>
				<category><![CDATA[3ds Max]]></category>
		<category><![CDATA[Maya]]></category>
		<category><![CDATA[maxscript]]></category>
		<category><![CDATA[technical]]></category>
		<category><![CDATA[16]]></category>
		<category><![CDATA[16 double]]></category>
		<category><![CDATA[3ds]]></category>
		<category><![CDATA[calculation]]></category>
		<category><![CDATA[conversion]]></category>
		<category><![CDATA[double]]></category>
		<category><![CDATA[matrices]]></category>
		<category><![CDATA[matrix]]></category>
		<category><![CDATA[matrix3]]></category>
		<category><![CDATA[Max]]></category>
		<category><![CDATA[transformation]]></category>
		<category><![CDATA[translation]]></category>
		<category><![CDATA[xform]]></category>
		<category><![CDATA[xformmat]]></category>

		<guid isPermaLink="false">http://blog.duber.cz/3ds-max/the-transformation-matrix-is-useful-when-understood</guid>
		<description><![CDATA[
The matrix in a 3D space has nothing to do with Neo&#8217;s hassle with sentinels, no, instead these are extremely useful and helpful vector arrays that make up a position, rotation and a scale of any object in your scene. Recently I&#8217;ve been re-inventing the wheel when I needed to write a system that&#8217;d allow [...]]]></description>
			<content:encoded><![CDATA[<p><img src='http://blog.duber.cz/wp-content/uploads/matrix_banner.png' alt='Matrix banner' /></p>
<p>The matrix in a 3D space has nothing to do with Neo&#8217;s hassle with sentinels, no, instead these are extremely useful and helpful <em>vector arrays</em> that make up a position, rotation and a scale of any object in your scene. Recently I&#8217;ve been <em>re-inventing the wheel</em> when I needed to write a system that&#8217;d allow me to instantly and without any user input transfer objects from Max to Maya and XSI. The reason for matrices in this case lies in the convenience of the whole matrix storing the object&#8217;s entire transformation information, which is, essentially, all that you need in order to accurately describe object&#8217;s exact position, rotation and scale in a 3D space.</p>
<p><span id="more-61"></span></p>
<p>The other reason is that Max is the only software (of these three) that has a differently aligned coordinate system. As opposed to XSI and Maya, Max&#8217;s <em>world up direction</em> is the Z axis, while Maya&#8217;s and XSI&#8217;s (default) <em>world up direction</em> is the Y axis. So, obviously, you cannot assume that when you move a box in Max 25 units along the X, Y and Z and rotate it 25 degrees along the, let&#8217;s say, Z axis, you&#8217;d get to the very same location and orientation when transferred to Maya or XSI. Not a chance!</p>
<p>So, how do you solve this problem? Well, thankfully, we have the transform matrix! As I said, every single entity in the 3D space (be it whatever, geometry objects, helpers, nulls, groups, vertices etc&#8230;) has its own transformation matrix so that it is explicitly given where the object is situated in the 3D space. There are many types of matrices, but the one we&#8217;re most interested in are the transform matrices. To cut the crap, a matrix is an <em>array</em> of values. This isn&#8217;t the most precise description of what a matrix is, but in a 3D package, the matrices are returned as a special type of an array. Let&#8217;s take a look at what you get when you ask Max and Maya for a special kind of a matrix an identity matrix. This is the matrix that describes the world&#8217;s coordinate system, it&#8217;s position, rotation and scale. This is the very basic matrix that every object, immediately after creation, transforms in it.</p>
<p>When you invoke a <code>matrix3 1</code> in Max, it returns this value: <code>(matrix3 [1,0,0] [0,1,0] [0,0,1] [0,0,0])</code> This is the identity matrix in Max. The very same identity matrix in Maya, as far as I know, cannot be created this way (but I&#8217;m almost 100% sure I just don&#8217;t know about the way yet), however, it can be queried from an object. If you create any object that&#8217;s perfectly aligned to the world and you ask for its matrix by invoking (in MEL) <code>xform -q -m `ls -sl`;</code> (assuming you&#8217;ve slected the object) you&#8217;ll get this: <code>Result: 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1</code> It may not seem so, but these two matrices are equal and, further more, are the very same, the only difference is that Maya returns a <em>16 double</em> value while Max returns a <em>matrix3</em> value. The other reason is that Maya&#8217;s matrix is a  square matrix of order 4-by-4 (4&#215;4), while Max&#8217;s matrix is of order 4-by-3 (4&#215;3), the last column is omitted as it&#8217;s always the same and has no special meaning for the user. So, how come they&#8217;re &#8220;the same&#8221;? Well, if you look at it this way:</p>
<p><img src='http://blog.duber.cz/wp-content/uploads/max_maya_matrix.png' alt='Max and Maya matrices' /></p>
<p>it should be clear that these identity matrices are exactly the same both in Max and Maya. There is one little problem, however. As I stated before, Maya&#8217;s and XSI&#8217;s default world&#8217;s up axis is the Y axis as opposed to Max&#8217;s Z axis. So, even though these identity matrices look exactly the same, they cannot be transferred between the packages as they are as that&#8217;d produce unwanted object transformation. What I needed for my project was a one-way conversion. I needed to <em>transform</em> Max&#8217;s transformation matrix into Maya&#8217;s transformation matrix. Thankfully it&#8217;s simpler than you might think. Generally, all you need to do is to transform your input transformation matrix into the Maya&#8217;s space, which can be done either from within Maya or directly within Max, or even outside in a separate program.</p>
<p>How exactly do you do that? And what is the Maya&#8217;s transformation matrix expressed inside Max? First things first. You have to know the Maya&#8217;s world transformation matrix relative to Max&#8217;s first in order to transform into that space. This can be easily generated in Max as all you have to do is to align a point helper (point helper because it can display it&#8217;s local axis tripod), manually, in Max so that it reflect&#8217;s Maya&#8217;s default Y axis as the world up axis. Then you ask for its transformation property, which will return this interesting value: <code>(matrix3 [1,0,0] [0,0,1] [0,-1,0] [0,0,0])</code> That&#8217;s it! That was the hardest part of the whole problem <img src='http://blog.duber.cz/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> Now you have Maya&#8217;s world transformation matrix inside Max, it can&#8217;t get any more exciting than that! Oks, just kidding, it actually does get more exciting than that! <img src='http://blog.duber.cz/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> Now it&#8217;s just a matter of transforming your transformation matrices into this space. How to go about this is simple. Thanks to a quick research on the internet and a few mathematical articles, I came across this formula:<br />
<code>(<br />
&nbsp;&nbsp;&nbsp;&nbsp;mayaMatrix = (matrix3 [1,0,0] [0,0,1] [0,-1,0] [0,0,0])<br />
&nbsp;&nbsp;&nbsp;&nbsp;inputMatrix = $foo.transform<br />
&nbsp;&nbsp;&nbsp;&nbsp;theResultingMatrix = mayaMatrix * inputMatrix * inverse mayaMatrix<br />
)</code></p>
<p>or, if you read user documentation <img src='http://blog.duber.cz/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> you come across this handy function:</p>
<p><code>(<br />
&nbsp;&nbsp;&nbsp;&nbsp;mayaMatrix = (matrix3 [1,0,0] [0,0,1] [0,-1,0] [0,0,0])<br />
&nbsp;&nbsp;&nbsp;&nbsp;inputMatrix = $foo.transform<br />
&nbsp;&nbsp;&nbsp;&nbsp;theResultingMatrix = xFormMat inputMatrix mayaMatrix<br />
)</code></p>
<p>(note: the local scope of this script is introduced just to make sure we won&#8217;t accidentally mess any existing variables up in your current namespace. If you don&#8217;t know what I&#8217;m talking about, just disregard this comment <img src='http://blog.duber.cz/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> )</p>
<p>The resulting matrix is an explicit transform matrix in Maya&#8217;s world space. It doesn&#8217;t get any more exciting than this! <img src='http://blog.duber.cz/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> So, at the end of the day I wrote a function that&#8217;ll also format the matrix3 value in a 16 double value so that Maya understands it and I could start seamlessly transforming objects from Max in Maya (I&#8217;ll leave this part to you). It may not seem too useful at first, but think of the possibilities! Besides I needed this conversion system for a much larger project I&#8217;m working on at the current studio that hired me. Let me put it this way: in the end, it&#8217;ll save us a lot of time, worrying, sleepless nights and company&#8217;s money! <img src='http://blog.duber.cz/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<p>Here&#8217;s a screenshot proving the concept:</p>
<p><a href="http://blog.duber.cz/wp-content/gallery/screenshots/max_maya_matrix_proof.png"  title="max_maya_matrix_proof.png" rel="lightbox[61]"><img src='http://blog.duber.cz/wp-content/gallery/screenshots/thumbs/thumbs_max_maya_matrix_proof.png' alt='max_maya_matrix_proof.png' title='max_maya_matrix_proof.png' /></a></p>
<p><strong>Recommended education:</strong></p>
<p><a href="http://en.wikipedia.org/wiki/Matrix_%28mathematics%29">Matrix (mathematics)</a><br />
<a href="http://en.wikipedia.org/wiki/Transformation_matrix">Transformation Matrix</a><br />
<a href="http://easyweb.easynet.co.uk/~mrmeanie/matrix/matrices.htm">Matrix Math</a><br />
<a href="http://paulneale.com/tutorials/matrix/TransformMatrix.htm">Paul Neale&#8217;s Transform Matrix tutorial</a><br />
<a href="http://cg-academy.net/pages/topic_maxscript/dvds_MAXScript_advanced_01/dvds_maxscript_advanced_01.php">The Matrix: Explained by Bobo</a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.duber.cz/3ds-max/the-transformation-matrix-is-useful-when-understood/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Scripting in Maya through Python? Get used to a lot of string operations.</title>
		<link>http://blog.duber.cz/3ds-max/you-want-to-script-in-maya</link>
		<comments>http://blog.duber.cz/3ds-max/you-want-to-script-in-maya#comments</comments>
		<pubDate>Wed, 14 May 2008 22:48:16 +0000</pubDate>
		<dc:creator>loocas</dc:creator>
				<category><![CDATA[3ds Max]]></category>
		<category><![CDATA[Maya]]></category>
		<category><![CDATA[Python]]></category>
		<category><![CDATA[maxscript]]></category>
		<category><![CDATA[technical]]></category>
		<category><![CDATA[3ds]]></category>
		<category><![CDATA[compare]]></category>
		<category><![CDATA[comparing]]></category>
		<category><![CDATA[comparison]]></category>
		<category><![CDATA[function]]></category>
		<category><![CDATA[loop]]></category>
		<category><![CDATA[Max]]></category>
		<category><![CDATA[operations]]></category>
		<category><![CDATA[parsing]]></category>
		<category><![CDATA[replacing]]></category>
		<category><![CDATA[scripting]]></category>
		<category><![CDATA[string]]></category>
		<category><![CDATA[while]]></category>

		<guid isPermaLink="false">http://blog.duber.cz/3ds-max/you-want-to-script-in-maya</guid>
		<description><![CDATA[
I find myself scripting in Maya more and more often. As I&#8217;ve expressed many times already, I really love and appretiate Python&#8217;s way of dealing with things, so having this language available in Maya is a blessing. The most beautiful part is when software actually does all the hard and annoying work for you  [...]]]></description>
			<content:encoded><![CDATA[<p><img src='http://blog.duber.cz/wp-content/uploads/maya_hypergraph_screenshot.png' alt='Maya hypergraph banner' /></p>
<p>I find myself scripting in Maya more and more often. As I&#8217;ve expressed many times already, I really love and appretiate Python&#8217;s way of dealing with things, so having this language available in Maya is a blessing. The most beautiful part is when software actually does all the hard and annoying work for you <img src='http://blog.duber.cz/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> Scripting in Maya using Python hadn&#8217;t been designed the way it should be. Unfortunately, Python only serves as a &#8220;wrapper&#8221; around MEL commands and MEL architecture. Fortunately there are attempts at simplifying Python scripting in Maya, such as PyMEL from <a href="http://www.luma-pictures.com/ncomPublish/index.html">Luma Pictures</a> (which is a studio I feel honored to cooperate with on <a href="http://www.imdb.com/title/tt1041804/">The Nutcracker: The Untold Story</a>), which is a fantastic &#8220;plug-in&#8221; for any Maya TD! which was, not surprisingly, done solely through Python itself <img src='http://blog.duber.cz/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> A fantastic demonstration of Python&#8217;s power. However, PyMEL isn&#8217;t the topic for this short post, maybe later, when I get more familiar with it and gain more experience using it.</p>
<p><span id="more-55"></span></p>
<p>The main reason for getting used to working and parsing a lot of string data is, as stated above, because, by default, Python acts as sort of a &#8220;wrapper&#8221; around Maya&#8217;s native MEL language. You&#8217;ll be passing tons of string arguments and parameters to Maya&#8217;s Python interpreter, so knowing how to deal with long strings is a must. Today I was solving a trivial issue of assigning numerous texture inputs to quite a few <em>tripleShadingSwitch</em> objects for some complex material and shader definition. The whole, manual, procedure would have been very straight forward, but extremely tedious and time consuming. So, as a TD, I was asked to write a little script that&#8217;d do the trick with a very limited user input, which basically meant no UI, which is a good thing for a scripter. If you&#8217;ve done some UI coding, you know what I&#8217;m talking about, especially in connection to Maya <img src='http://blog.duber.cz/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<p>In the end, I dealt with a lot of string variables that were passed throughout the script in Python. It&#8217;d have been a pain in the ass doing this sort of thing in MAXScript, as MAXScript isn&#8217;t very &#8220;string friendly&#8221;. I mean, of course there are various string functions available, but they don&#8217;t come even close to waht Python has to offer!  A single Python module, called &#8220;string&#8221;, did all and much more I needed. For example, after importing the module, I was able to, very effectively, break a string down based on a keyword argument and separate individual words. While this concrete example is very easily doable in MAXScript, not so easily doable in MEL, there are many other examples that aren&#8217;t so easy to do in MAXScript or MEL in comparison to Python. One example for all. Let&#8217;s say you have to deal with namespaces. They usually occur in applications like Maya or MotionBuilder which preven users from naming individual objects the same name under the same level in a hierarchy. When you have multiple hierarchies, you may bump into objects with the same name. Maya will return the shortest namespace possible, so instead of returning a &#8220;Sphere1&#8243; it&#8217;ll return a &#8220;myHierarchy|secondLevel|thirdLeve|Sphere1&#8243; if multiple objects with this particular name exist in the scene. So, for whatever reason, what if you need to replace the specific namespace separator with something else? Here&#8217;s an example of a very long string of several words separated with a colon (as it&#8217;s a common character for identifyingnamespaces) that you want to replace by an underscore character, let&#8217;s say for compatibility reasons (say you want to pass this string to Max). Here&#8217;s how to do it in Python (including Python in Maya):</p>
<p><code>from string import *<br />
aVeryLongString = "a:very:very:very:very:long:string:with:namespaces"<br />
aNewString = replace(aVeryLongString,":","_")</code></p>
<p>the result: <em>a_very_very_very_very_long_string_with_namespaces</em></p>
<p>Great! Only three lines of code and very little brain usage was actually needed to perform this task <img src='http://blog.duber.cz/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> How about MAXscript? Well, MAXscript has a function called <em>replace()</em>, the problem is, it expects a string, a start position, a number of characters it should replace and an actual new string that&#8217;ll replace the old ones. Certainly usable, but very inconvenient, especially for casual or beginner scripters. How do you go about this limitation? You can&#8217;t import a &#8220;string&#8221; module or anything like that in MAXScript, so you have to write your own, custom, function to do that for you, which would be one of many ways to solve this little issue. For this example, I wrote a custom function that mimics Python&#8217;s <em>replace()</em> functino behavior including the number and nature of arguments it requires.</p>
<p><code>aVeryLongString = "a:very:very:very:very:long:string:with:namespaces"<br />
fn replaceAll str old kwrd =<br />
(<br />
&nbsp;&nbsp;&nbsp;&nbsp;while findString str old != undefined do<br />
&nbsp;&nbsp;&nbsp;&nbsp;(<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;str = replace str (findString str old) kwrd.count kwrd<br />
&nbsp;&nbsp;&nbsp;&nbsp;)<br />
&nbsp;&nbsp;&nbsp;&nbsp;return str<br />
)<br />
replaceAll aVeryLongString ":" "_"</code></p>
<p>the result: <em>a_very_very_very_very_long_string_with_namespaces</em></p>
<p>Basic break down: the function takes three arguments, the actual string you want to work with, and old character you want to replace (it supports more than one character) and a new, keyword (kwrd) to replace with. When invoked, it goes through a <em>while</em> loop to search for the <em>old</em> character string and replaces it with the new <em>kwrd</em> character string. After it&#8217;s all done it returns the new string.</p>
<p>Even though this took only a few more lines of code, I used two string specific functions and a loop clause all wrapped up in a custom function to do the trick for me. Besides, as I already mentioned, this method is much more complex and hard to code for an inexperienced scripter who just wants to perform a simple character replacement function. These are the tiny little differences that may cause a lot of trouble and headaches when developing really complex and large scripts or, for example, when you have a Junior TD at the studio who should help you out with simpler, smaller tasks and they bump into some similar problem like this one, which it&#8217;s as if they weren&#8217;t there since you end up doing the work yourself anyways.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.duber.cz/3ds-max/you-want-to-script-in-maya/feed</wfw:commentRss>
		<slash:comments>17</slash:comments>
		</item>
		<item>
		<title>Serious technical limitations of proprietary languages.</title>
		<link>http://blog.duber.cz/3ds-max/serious-technical-limitations-of-proprietary-languages</link>
		<comments>http://blog.duber.cz/3ds-max/serious-technical-limitations-of-proprietary-languages#comments</comments>
		<pubDate>Tue, 13 May 2008 14:43:33 +0000</pubDate>
		<dc:creator>loocas</dc:creator>
				<category><![CDATA[3ds Max]]></category>
		<category><![CDATA[Maya]]></category>
		<category><![CDATA[Python]]></category>
		<category><![CDATA[maxscript]]></category>
		<category><![CDATA[opinions]]></category>
		<category><![CDATA[software]]></category>
		<category><![CDATA[technical]]></category>
		<category><![CDATA[.NET]]></category>
		<category><![CDATA[3ds]]></category>
		<category><![CDATA[ADODB]]></category>
		<category><![CDATA[Autodesk]]></category>
		<category><![CDATA[connection]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[db]]></category>
		<category><![CDATA[Max]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[OLE]]></category>
		<category><![CDATA[open]]></category>
		<category><![CDATA[open-source]]></category>
		<category><![CDATA[opensource]]></category>
		<category><![CDATA[source]]></category>

		<guid isPermaLink="false">http://blog.duber.cz/3ds-max/serious-technical-limitations-of-proprietary-languages</guid>
		<description><![CDATA[The more time you spend developing some more complex tools and code, the more you start appretiating all the open-source tools and add-ons you can get. Thankfully, Max and its MAXScript language is very widely used throughout the CG community, so, some times you don&#8217;t even have to start developing your own tools from scratch, [...]]]></description>
			<content:encoded><![CDATA[<p>The more time you spend developing some more complex tools and code, the more you start appretiating all the open-source tools and add-ons you can get. Thankfully, Max and its MAXScript language is very widely used throughout the CG community, so, some times you don&#8217;t even have to start developing your own tools from scratch, you can get either the whole package from sites like ScriptSpot or at least build your tools up on somebody else&#8217;s script. However, there are certain limitations that even a huge community, such as the one Max has, won&#8217;t be of much help.</p>
<p><span id="more-53"></span></p>
<p>I&#8217;ve been recently doing quite a lot of R&amp;D on XML, MySQL etc&#8230; in conjunction with Max and/or Maya and I constantly bump into obstacles when building the same code I did in Maya through Python, in MAXScript. The problem is, MAXScript is a proprietary language and therefore, you&#8217;re stuck with what you have. It&#8217;s a great, easy to learn and easy to master language, don&#8217;t get me wrong, but if you&#8217;re missing some specific features, you&#8217;re pretty much doomed. There are some extensions to be found on the net for MAXScript, but usually, they were done by a guy in similar situation you find yourself, but with extensive knowledge of Max&#8217;s SDK and C++/C# programming. I, unfortunately, have very limited knowledge of C++/C# programming and therefore I 100% rely on what I can find on the internet.</p>
<p>On the other hand, Python, for example, is an open-source scripting language. Very mature, very popular, ver widely accepted. This leads to a lot of individual, task specific, modules. So, in my case, recently, when I needed to write to or read from a XML file, I simply downloaded a <a href="http://pyxml.sourceforge.net/topics/">PyXML</a> package, read briefly the documentation, skimmed through some sample code and in a few hours I was able to write my own procedures to derive data from XML files and write them back to another XML. MAXscript doesn&#8217;t have any dedicated procedures/functions for such a task, so you either end up writing your own functions for this purpose, which is rather time consuming or you try your luck and try to search the internet for some already finished code, if there&#8217;s any. Same deal with the MySQL connection I was dealing with recently. Again, MAXScript doesn&#8217;t provide an extensive way of connecting to a database, it has an AODB object, which is quite limiting and a bit outdated nowdays. Thankfully, there seems to be a solution through dotNET objects, but I can&#8217;t use this method in Max prior to version 9 (you may not believe it, but I still prefer Max 8 nowdays <img src='http://blog.duber.cz/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> ).</p>
<p>So, as you can see, languages such as Python are really a smart way to write your tools in and based your pipeline around. Obviously, Python isn&#8217;t the only scripting language of this kind, but it&#8217;s very popular and widely spread. I also highly recommend it because of its simple syntax, yet robust toolset. A very smart and far-sighted move from Guido van Rossum, kudos!</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.duber.cz/3ds-max/serious-technical-limitations-of-proprietary-languages/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>I&#8217;m loving Python!</title>
		<link>http://blog.duber.cz/3ds-max/im-loving-python</link>
		<comments>http://blog.duber.cz/3ds-max/im-loving-python#comments</comments>
		<pubDate>Sun, 02 Mar 2008 13:20:20 +0000</pubDate>
		<dc:creator>loocas</dc:creator>
				<category><![CDATA[3ds Max]]></category>
		<category><![CDATA[Maya]]></category>
		<category><![CDATA[Python]]></category>
		<category><![CDATA[maxscript]]></category>
		<category><![CDATA[opinions]]></category>
		<category><![CDATA[software]]></category>
		<category><![CDATA[technical]]></category>
		<category><![CDATA[3ds]]></category>
		<category><![CDATA[Autodesk]]></category>
		<category><![CDATA[choose]]></category>
		<category><![CDATA[difference]]></category>
		<category><![CDATA[differences]]></category>
		<category><![CDATA[how]]></category>
		<category><![CDATA[language]]></category>
		<category><![CDATA[languages]]></category>
		<category><![CDATA[Max]]></category>
		<category><![CDATA[MEL]]></category>
		<category><![CDATA[MXS]]></category>
		<category><![CDATA[scripting]]></category>
		<category><![CDATA[which]]></category>

		<guid isPermaLink="false">http://blog.duber.cz/opinions/im-loving-python</guid>
		<description><![CDATA[
Interestingly enough, when I started looking into extending my technical skills and knowledge beyond 3ds Max itself at first I got a bit frustrated. The reason was I thought (as probably many other technical artists out there, based on many discussions I read) that I spent years developing some scripting and technical skills to find [...]]]></description>
			<content:encoded><![CDATA[<p><img src='http://blog.duber.cz/wp-content/uploads/max_maya_python.png' alt='max_maya_python.png' /></p>
<p>Interestingly enough, when I started looking into extending my technical skills and knowledge beyond 3ds Max itself at first I got a bit frustrated. The reason was I thought (as probably many other technical artists out there, based on many discussions I read) that I spent years developing some scripting and technical skills to find out they were useless and I&#8217;ll have to learn something entirely different in order to stay at the cutting edge and still being competitive. Now while 3ds Max isn&#8217;t a factor here, it&#8217;s just a platform anyways, I dived into Maya recently and faced a, seemingly, difficult decision: do I go the MEL way or do I learn Python (available in Maya since 8.5)? The decision turned out to be petty simple! I&#8217;ll learn both! As I devoured the user reference files, some tutorials and some books, I found out that once you learn one scripting language syntax and logic, picking up any other (similar) language is quite easy.</p>
<p><span id="more-38"></span></p>
<p>Well, MEL, out of the three, comparatively, is the most difficult to grasp, not because of the sheer number of functions and attributes, but because the syntax is a bit too complicated (to my tastes) and the integration of MEL in Maya is also a little too restrictive (compared to MAXScript that I&#8217;m coming from). Now, the fact that Maya supports Python (too bad Max doesn&#8217;t natively support it as well), even though in a bit of a &#8220;MEL falvour&#8221; is pretty cool and only thanks to this fact I was able to pick up scripting in Maya very, very quickly! So, what&#8217;s so special about Python? Python is extremely easy to learn! Let me compare complexity-wise the three: Python < MAXScript < MEL and if I was to compare the three feature-wise: Python > MEL > MAXScript, so the clear winner is Python. Now, I&#8217;m primarily a 3ds Max TD, therefore I&#8217;m not able to fully appretiate Python&#8217;s power and strength from within Max, or am I? Thanks to the ever-so-awesome folks at <a href="http://www.blur.com">Blur</a> and their dedication to using 3ds Max in their pipeline, we have something that&#8217;s called &#8220;blurPython&#8221; which is an extension to MAXScript that allows you to call Python functions and modules. This alone takes scripting in Max to a whole new level! Even though you don&#8217;t have a direct Python syntax support in Max, you can&#8217;t call Max&#8217;s functions with Python (sort of, you can do that actually but it hasn&#8217;t got much to do with Python itself) you can access Python modules and functions from within Max, which is awesome. Now think about the feature set of Python, the fact that Python has been around for longer than Max itself and that it really is a production proven scripting framework and you&#8217;ve got a one hell of a powerful weapon in your TD arsenal! Especially if you&#8217;re into building custom pipelines and data sharing!</p>
<p>This article isn&#8217;t that much about all the posibilities you can do with Python itself, I&#8217;d rather like to compare some features of MEL, MXS (MAXScript) and PY (Python). So, first things first. When I started exploring Maya&#8217;s scripting and its logic, I buped several times into my old habbits of code testing, exploring and writing that I carried from Max. Some examples, when developing some code I tend to setup a bunch of testing global variables in order to speed up some UI testing, cut down on number of clicks in order to test out some tools with more complex UI etc&#8230; So I started developing some primitive scripts in Maya that were a bit ahead of <code>print "YAY!\n";</code> :D. Very soon I bumped in MEL&#8217;s design &#8220;limitation&#8221; (it&#8217;s not a limitation so to speak, only in my eyes it looks like a limitation, while in fact it&#8217;s simply a matter of design), I cannot reassign a different value class to an already declared variable. Let me explain: MXS allows me to do the following: <code>global testVar = "Hello!"; testVar = 10</code> which means: globally declare a variable called &#8220;testVar&#8221; and assign it a string value of &#8220;Hello!&#8221; then try to assign it an integer value of &#8220;10&#8243;. MEL won&#8217;t let you do this, which was to me, as a starting MEL scripter, quite confusing. The problem got more serious and I got frustrated even more when I learned that there was no way of &#8220;undeclaring&#8221; variables in MEL, so the &#8220;testVar&#8221; was available all the time during the session (which means until I restarted Maya). So, as recommended, you should always test your code in a local scope in MEL, which means writing your code within two curly braces: &#123; &lang;your code&rang; &#125;</p>
<p>This was quite shocking to me as a MXS scripter that I didn&#8217;t have the freedom to reassign variables with different value classes. Further on, the limitation touched all the aspects of the language I was used to, like arrays that can only carry a predefined value class, you can&#8217;t mix up integers with strings for example in MEL&#8217;s arrays (lists). So I put up with the fact and tried to learn a &#8220;different&#8221; syntax. I spent about 2 weeks learning MEL intentionally avoiding Python in Maya as, at first, I thought it was some kind of a &#8220;second layer&#8221; language above MEL that won&#8217;t do much difference in Maya. Oh, how wrong I was! Python, in fact, is much more powerful (to my surprise) in Maya than MEL. You can do the same with Python in Maya as you can with MEL, however, you can do much more with Python than you can do with MEL! This is quite interesting and since before MEL I had been looking into Python a bit, I got interested in it even more.</p>
<p>Everybody on the net says how easy, yet powerful, Python really is, I had to prove it to myself and started looking into the syntax and general Python logic. How glad and happy was I when I discovered that you CAN reassign different class values to a single variable (just like in MXS), I can mix up array (list) item classes any way I like (same as MXS), but the real surprise came when I realized that the PY syntax indeed was easy, so easy that I even think that it&#8217;s easier than MXS! And MXS really is easy to pick up and code in, believe me.</p>
<p>Ok, let&#8217;s take a look at some examples that I discovered which are very important in scripting in general. The globally declared variables in PY and MXS can be reassigned with a different value class! MEL doesn&#8217;t support this feature.</p>
<p>Python:<br />
<code>varA, varB, varC = 10, 20, 30<br />
print varA, varB, varC<br />
varA, varB, varC = "It", "just", "works"<br />
print varA, varB, varC</code></p>
<p>MAXScript:<br />
<code>varA = 10; varB = 20; varC = 30<br />
print varA; print varB; print varC<br />
varA = "It"; varB = "just"; varC = "works"<br />
print varA; print varB; print varC</code><br />
(notice the difference, Python actually supports multiple variable assignments on a single line in order as opposed to MXS)</p>
<p>MEL:<br />
<code>&#123;<br />
&nbsp;&nbsp;&nbsp;$varA = 10&#59; $varB = 20&#59; $varC = 30&#59;<br />
&nbsp;&nbsp;&nbsp;print ($varA+"\n"); print ($varB+"\n"); print ($varC+"\n")&#59;<br />
&nbsp;&nbsp;&nbsp;$varA = "It"; $varB = "just"; $varC = "works"&#59;<br />
&nbsp;&nbsp;&nbsp;print ($varA+"\n"); print ($varB+"\n"); print ($varC+"\n")&#59;<br />
&#125;</code><br />
Notice that MEL won&#8217;t let you reassign a different value class to an already created variable! It&#8217;ll try to convert the new class input to the one implicitly created. So, the code above will actually result in:</p>
<blockquote><p>// Warning: $varA = &#8220;It&#8221;; $varB = &#8220;just&#8221;; $varC = &#8220;works&#8221;; //<br />
// Warning: Converting string &#8220;It&#8221; to an int value of 0. //<br />
// Warning: $varA = &#8220;It&#8221;; $varB = &#8220;just&#8221;; $varC = &#8220;works&#8221;; //<br />
// Warning: Converting string &#8220;just&#8221; to an int value of 0. //<br />
// Warning: $varA = &#8220;It&#8221;; $varB = &#8220;just&#8221;; $varC = &#8220;works&#8221;; //<br />
// Warning: Converting string &#8220;works&#8221; to an int value of 0. //<br />
// Result: 0 //</p></blockquote>
<p>Now, let&#8217;s take a look at loops. These are most common in any scripter&#8217;s arsenal so you really have to learn how to write these in order to process repetitive tasks!</p>
<p>Python:<br />
<code>for i in range(1, 10, 2):<br />
&nbsp;&nbsp;&nbsp;print i</code></p>
<p>MAXscript:<br />
<code>for i = 1 to 10 by 2 do(print i)</code></p>
<p>MEL:<br />
<code>&#123;<br />
&nbsp;&nbsp;&nbsp;for ($i = 1; $i < 10; $i+=2)<br />
&nbsp;&nbsp;&nbsp;&#123;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;print ($i+"\n");<br />
&nbsp;&nbsp;&nbsp;&#125;<br />
&#125;<br />
</code><br />
(notice that I put the MEL code in a local scope)</p>
<p>The MAXScript syntax in this case is far easier to read than Python and especially then MEL (also notice how many extra characters you have to put in the code in order to achieve the same result)</p>
<p>Another very useful feature is functions (in MEL they're called procedures). I'm yet into learning what all is possible with functions in Python, but what I've learnt so far is quite enough for my needs.</p>
<p>Python:<br />
<code>def sumTheNumbers(num1, num2):<br />
&nbsp;&nbsp;&nbsp;return num1+num2<br />
sumTheNumbers(10, 20) #call the function with some input numbers of choice<br />
sumTheNumbers("You ", "can!") #notice that Python doesn't actually care what class of variables you throw at it as long as it can perform the required task</code></p>
<p>MAXScript:<br />
<code>fn sumTheNumbers num1 num2 =<br />
&nbsp;&nbsp;&nbsp;(<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return num1+num2<br />
&nbsp;&nbsp;&nbsp;)<br />
sumTheNumbers 10 20 -- call the function with some input numbers of choice<br />
sumTheNumbers "You " "can!" -- notice that MAXScript doesn't actually care what class of variables you throw at it as long as it can perform the required task</code><br />
(same thing, MAXScript is also "kind" to the user as to letting them assigning different value classes and performs the operations on them, if possible.)</p>
<p>MEL:<br />
<code>&#123;<br />
&nbsp;&nbsp;&nbsp;proc int sumTheNumbers(int $num1,int $num2)<br />
&nbsp;&nbsp;&nbsp;&#123;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return $num1+$num2&#59;<br />
&nbsp;&nbsp;&nbsp;&#125;<br />
&nbsp;&nbsp;&nbsp;print(sumTheNumbers(10, 20)+"\n")&#59; // call the function with some input numbers of choice (from within a print() function in order to see the result)<br />
&nbsp;&nbsp;&nbsp;print(sumTheNumbers("You ", "can't!")+"\n")&#59; // MEL will automatically convert the input classes to integer class, if possible<br />
&#125;</code><br />
(notice that I just declared an INTEGER procedure that expects two INTEGER values to be passed to it, so, there's no way you could summarize two floats (i.e.: 10.0 and 20.0) or even strings (i.e.: "You " and "can't!") and expect MEL to return float or string values respectively. What MEL will do is it'll convert the incoming value classes to, in this case, integers, if possible, and then performs the required calculations!</p>
<p>So, there you go, these were basic and simplyfied examples of the different languages. The conclusion could be stated as Python being the superior language to MXS and MEL and its syntax being most conformable to MAXScript (or rather the oposite, MAXScript being very conformable o Python, as MAXscript is younger). There are, of course, much, much deeper differences or similarities that wasn't the purpose of this article to bring up. I'm yet to learn Python more deeply myself, so I can't name more concrete, deeper, differences among the languages. However, if you're facing the same problem (which language to learn) coming from 3ds max, I'd recommend both, MEL and Python. I learnt MEL marginally just to get a glimpse of how it works and how it treats user input and then I went to Python for its much cleaner and easier syntax and much wider possibilities.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.duber.cz/3ds-max/im-loving-python/feed</wfw:commentRss>
		<slash:comments>21</slash:comments>
		</item>
	</channel>
</rss>
