This blog was going to be about how I failed to make a working maxScript in 3dsMax. I had successfully made the script , but due to an oddity (in my opinion) in 3dsMax, I didn’t realise it at the time. It wasn’t until I was taking screen captures that I realised that my script actually worked.
The problem I tried to overcome,was that, coming from an animation background, I know that you have to go in and physically change the rotation of the pivot point before you export the asset as an FBX file. Even though you check the Y-axis up box, it still doesn’t change the rotation of the pivot point which can cause problems trying to code the models in Unity when the Z axis is pointing to the sky. This process can be a pain if there are several items in the scene.
The first step was to research maxScripts and the MaxScript Listener (http://www.polycount.com/forum/showthread.php?t=84895 and http://knowledge.autodesk.com/support/3ds-max/getting-started/caas/CloudHelp/cloudhelp/2015/ENU/3DSMax-Tutorial/files/GUID-4FB4F8E4-0B7C-4417-B725-B0700714A4F9-htm.html?v=2015).
Just using the Listener methods to try and record my actions, I created a small script that looked a bit like this.
My initial scene looked like this:
After executing the script, it looked like this:
This wasn’t the desired result. I did try a variation of the script, whereby I then went back out of the Hierarchy Mode and rotated the model -90 on that same axis but after executing that script, the model was the same as it was before executing the script. This did forewarn me about a potential problem I could be facing.
I later found a great deal of useful information at this site: http://docs.autodesk.com/3DSMAX/16/ENU/MAXScript-Help/index.html?url=files/GUID-624D3D05-B15D-4A97-9F15-DA35CDB0DDD2.htm,topicNumber=d30e703708. Typical of AutoDesk to have nearly all of the relevant documentation available to designers 😉
Another valuable source for me was http://www.neilblevins.com/cg_tools/soulburnscripts/soulburnscripts.htm which has a lot of scripts available to do a great many things in Max, except the thing that I wanted to do. Blevin gave me the clue that I need to get into the XForm and rotate the gizmo. This will however create a new modifier in the Modifier List, which will have to be collapsed when the model is converted to an Editable Poly again. From my Listener script, I took a gamble that I would meed to rotate the mesh in the opposite direction.
While they are older videos, there is some good content in her to help with rollouts .. https://vimeo.com/album/1514565/page:1/sort:preset/format:thumbnail.
The problem for me was, when running my script, I dragged it from the Dialogue Box into my scene. I didn’t, however, close this damn dialogue box and no matter how many times I tried to get it to work, it just wouldn’t work properly. It was rotating the pivot point to the correct direction, but there were issues with the model’s movement and the fact the I couldn’t delete it. Even starting a new scene, the model still came up. I put this down to some bugs in my code. What I didn’t know is that the code would have worked if I closed the dialogue box.
Once this had been discovered, it was full steam ahead and referring to this site http://knowledge.autodesk.com/search-result/caas/CloudHelp/cloudhelp/2015/ENU/MAXScript-Help/files/GUID-6E21C768-7256-4500-AB1F-B144F492F055-htm.html, it was a simple matter to create the macro by dragging the text of the program into the toolbar and assigning an icon to the new button.
Here are some screen grabs showing the process and result of changing the y axis.
In summation. I could have finished this off so much earlier this weekend, but for the Open Script dialogue box. Pro Tip: Close dialogue boxes in Max before testing to see if your code is working properly.