[Bf-extensions-cvs] SVN commit: /data/svn/bf-extensions [2603] trunk/py/scripts/addons/ io_export_after_effects.py: In convert_lens() changed 'try' test to ' hasattr' test (Campbell Barton's suggestion, thank you), added '_' between prefix and ob_name to get more readable layers' names in AE, plus minor spelling corrections.

Bartek Skorupa bartekskorupa at bartekskorupa.com
Sat Nov 12 12:15:49 CET 2011


Revision: 2603
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-extensions&revision=2603
Author:   bartekskorupa
Date:     2011-11-12 11:15:44 +0000 (Sat, 12 Nov 2011)
Log Message:
-----------
In convert_lens() changed 'try' test to 'hasattr' test (Campbell Barton's suggestion, thank you), added '_' between prefix and ob_name to get more readable layers' names in AE, plus minor spelling corrections.

Modified Paths:
--------------
    trunk/py/scripts/addons/io_export_after_effects.py

Modified: trunk/py/scripts/addons/io_export_after_effects.py
===================================================================
--- trunk/py/scripts/addons/io_export_after_effects.py	2011-11-11 23:46:05 UTC (rev 2602)
+++ trunk/py/scripts/addons/io_export_after_effects.py	2011-11-12 11:15:44 UTC (rev 2603)
@@ -90,7 +90,7 @@
         ob_name = prefix + ob
         ob_name = ob_name.replace('"', "_")
     else:
-        ob_name = prefix + ob.name
+        ob_name = prefix + "_" + ob.name
 
         if ob_name[0].isdigit():
             ob_name = "_" + ob_name
@@ -148,13 +148,13 @@
 #     - sensor height (camera.data.sensor_height)
 #     - sensor fit (camera.data.sensor_fit)
 #     - lens (blender's lens in mm)
-#     - width (witdh of the composition/scene in pixels)
+#     - width (width of the composition/scene in pixels)
 #     - height (height of the composition/scene in pixels)
 #     - PAR (pixel aspect ratio)
 #
-# Calculations are made using sensor's size and scene/comp dimention (width or height).
-# If camera.sensor_fit is set to 'AUTO' or 'HORIZONTAL' - sensor = camera.data.sensor_width, dimention = width.
-# If camera.sensor_fit is set to 'VERTICAL' - sensor = camera.data.sensor_height, dimention = height
+# Calculations are made using sensor's size and scene/comp dimension (width or height).
+# If camera.sensor_fit is set to 'AUTO' or 'HORIZONTAL' - sensor = camera.data.sensor_width, dimension = width.
+# If camera.sensor_fit is set to 'VERTICAL' - sensor = camera.data.sensor_height, dimension = height
 #
 # zoom can be calculated using simple proportions.
 #
@@ -166,7 +166,7 @@
 #       e  |  \     /         | m
 #       n  |    \ /           | e
 #       s  |    / \           | n
-#       o  |  /     \         | t
+#       o  |  /     \         | s
 #       r  |/         \       | i
 #                       \     | o
 #          |     |        \   | n
@@ -174,25 +174,25 @@
 #          |     |            |
 #           lens |    zoom
 #
-#    zoom / dimention = lens / sensor   =>
-#    zoom = lens * dimention / sensor
+#    zoom / dimension = lens / sensor   =>
+#    zoom = lens * dimension / sensor
 #
 #    above is true if square pixels are used. If not - aspect compensation is needed, so final formula is:
-#    zoom = lens * dimention / sensor * aspect
+#    zoom = lens * dimension / sensor * aspect
 #
 def convert_lens(camera, width, height, aspect):
-    try:  # wrap in "try" to preserve compatibility with older versions not supporting camera sensor size.
+    if hasattr(camera.data, "sensor_width"):  # Preserve compatibility with versions not supporting camera sensor.
         if camera.data.sensor_fit == 'VERTICAL':
             sensor = camera.data.sensor_height
-            dimention = height
+            dimension = height
         else:
             sensor = camera.data.sensor_width
-            dimention = width
-    except:
+            dimension = width
+    else:
         sensor = 32  # standard blender's sensor size
-        dimention = width
+        dimension = width
     
-    zoom = camera.data.lens * dimention / sensor * aspect
+    zoom = camera.data.lens * dimension / sensor * aspect
 
     return zoom
 



More information about the Bf-extensions-cvs mailing list