Maya Ascii camera export script

Perhaps installing the 64-bit AMD Python 2.6.2 will have the full package:

http://www.python.org/ftp/python/2.6.2/python-2.6.2.amd64.msi

Others reported a similar issue earlier and used the 32-bit Python + 32-bit Blender. The Tkinter call is just for the native dialog. As a fallback, I should put in Blender’s dialog but tkinter is the standard GUI API in Python so it should be fully supported with the right installation. I much prefer the popup system dialog and hope it becomes standard in Blender some day.

EDIT:
I have updated the script ( http://dev-art.co.uk/files/tracking.py.zip ) with an option to limit the export types again, this means you can choose to only export certain types like cameras and nulls, which makes exports on scenes with lots of objects much quicker.

I also added in a fallback so if you don’t have tkinter in the Python installation, it will revert back to Blender’s built-in file browser.

There’s also a couple of optimizations that improve export by about 20%.

said it before, say it again…
LEGEND!!!

Nice one OSXrules! Works a treat!

Hi,

Thank you so much Osxrules for all your work and help. The script now works in both 32 and 64 versions of Blender.
However, I have a problem with the camera not matching in AE both CS3 and CS4. The mismatch only occurs if rotation is added in the camera animation. I position is the only thing animated the track is spot on. The Nulls in AE appear to moving in the opposite direction to what the look like they should.
Is there a work around for this, is this something Im doing wrong. If any one can shed some light on this it would be most appreciated.
Once again thank you for your hard work in providing this script.

Kind regards,

Bopstar :slight_smile:

Has this arisen in a newer version of the script or did it always do this and is the mismatch small or large?

Also, what are your output settings for your frame size? It’s best if they match exactly, for example don’t use Blender’s aspect ratio drop downs for widescreen - they seem to differ slightly from AE. For widescreen DVD, render as 1024 x 576 with aspect 1:1.

If you have an example .blend and AEP (CS3) file I can use, that would help. I’ll check it out myself and see if I notice a mismatch. The movements should be accurate now as they match the settings in Maya.

Hi Again,
Osxrules thank you so much for your prompt reply it is most appreciated.
All the setting are fine and have tried various output setting to see if the problem was there. I will install an earlier version of the script to see if the problem is with the updated one.
Is there a place were I can post the project files?
Thanks for all your help.

Kind Regards,

Bopstar

If you can zip them and use Rapidshare ( http://www.rapidshare.com/ ), that would work.

Hi Osxrules,

I’ll do that, but first I will test the earlier script, to see if that is where the problem is.

Thanks again.

Regards,

Bopstar.

Osxrules,

thanks as usual for keep working on this essential script.
I’m getting some weird rotation coordinates, please, could you have a look at this file?
http://phoenixart.com/temp/Blender3D/camera-export/camera-export folder.7z

Thanks in advance.

I can see the problem. It is to do with the rotation I had to add to fix the AE particles plugin - the problem that comes from Blender’s scene being the wrong way round from everybody else.

At first I thought it was just a single rotation value being wrong but even with that corrected, the tracking is still off, check it out:

http://dev-art.co.uk/files/tracking-test.py.zip

It’s weird though because I’m not scaling any of the values by an odd amount and the exported scene looks almost the same in Maya as it does in Blender but I when I overlap the screenshots, they are out by a fixed rotation (3-4 degrees) around the x-axis.

It took ages trying to figure out which way to rotate the values to work and clearly they’re still wrong.

Hi Osxrules,

The earlier version of the script that I have works great. I have the project files if you still need them.

http://rapidshare.com/files/273432587/Projects.zip.html

Thanks once again.

Kind Regards,

Bopstar.

Thanks for uploading those. I was testing Phoenixart’s scene and it’s just really strange how rotating the scene round so that Y is up throws it out for rotation. I’ve reverted the latest script back to having Z up and the tracking seems to be ok, even in Maya except obviously it’s on its side and there’s a lag on one of the objects rotating in Phoenixart’s scene for some reason.

Use this script for the time being so that the tracking is ok and you still get all the other improvements and I’ll try and figure out how to get Y-up without messing up the rotation tracking:

http://dev-art.co.uk/files/tracking-z-up.py.zip

Ok, the problem was caused by the totally random rotation I decided to use because it looked like it worked. Ideally, I should just apply a 90 degree rotation around the x-axis but Python rotates around the local center instead of the world center.

One solution that works is to parent the whole scene to an empty and rotate that. Unfortunately, it dumps a whole bunch of other objects into the AE scene, which is kinda stupid as there is only one empty transform.

EDIT: figured out how to do a rotation around a given center. For future reference, you do 3 matrix transforms. First translate to the desired center, then rotate, then move back to where you were.

To do a world space rotation for example do the following:

// construct 4x4 inverse translation matrix to go to world space 0,0,0
tInv = obj.getInverseMatrix().translationPart()
tInvM = Matrix([1,0,0,tInv.x],[0,1,0,tInv.y],[0,0,1,tInv.z],[0,0,0,1])

// construct 4x4 translation matrix to move back
ttM = obj.getMatrix().translationPart()
tM = Matrix([1,0,0,ttM.x],[0,1,0,ttM.y],[0,0,1,ttM.z],[0,0,0,1])

// take object matrix, move to rotation center, rotate, move back
matrix = obj.getMatrix()tInvMmx*tM

http://dev-art.co.uk/files/tracking.py.zip

There still seems to be a rotation lag with Phoenixart’s scene on the rotating text that still needs fixed.

Thanks Osxrules so much for taking the time to go through this, your time and effort is greatly appreciated.

Bopstar :slight_smile:

hey Osxrules,

thanks again, the update works much better!
needless to say how important this script is and what it means for the mograph scene.

Are you noticing the lag on the rotation of the text object in your example scene? I don’t see what’s causing that. The rotation matches Maya exactly in top view and yet in AE, it starts ok but then seems like it slows down and then finishes ok.

Yes, I’ve noticed that problem, but the rest of nulls and coordinates seem to work fine.
Btw, actually it’s strange the behavior of the null font…

Hi!
I have a problem with the script in hd it seem that when I import my camera from blender in after effect the movement seem to track perflectly in time but it is way of in term of Y axis. it seem like it is under my scene. Thx for your help

im having trouble with the script. When i try to run it i get a ‘Python script error: check console’ error … im running blender 2.49b on mac os x 10.5.8 (PPC)

Can you upload your .blend to rapidshare or similar and post the link or PM the link if you don’t want the .blend to be public. When you say hd, do you mean e.g 720p?

The console is in /Applications/Utilities. If it doesn’t list the error message, try launching Blender inside a terminal by going to the Blender app, right-click > show package contents, go to Contents/MacOS and double-click the blender file in there. It will likely open fullscreen but you can choose the window > zoom menu option to put it back. The output from the script should then show in the terminal window that opened.

hey, i did as you said. This is what is in the console … i have no idea what it means …

Compiled with Python version 2.3.5.
Checking for installed Python... got it!
Traceback (most recent call last):
  File "<string>", line 1, in ?
  File "/Applications/Blender/Blender.app/Contents/MacOS/.blender/scripts/tracking.py", line 207
    if not pvals.has_key(name): pvals[name] = dict((p,[None,None]) for p in attrlist)
                                                                     ^
SyntaxError: invalid syntax