[Bf-extensions-cvs] SVN commit: /data/svn/bf-extensions [2744] trunk/py/scripts/addons: minor edits
Campbell Barton
ideasman42 at gmail.com
Tue Dec 6 18:40:41 CET 2011
Revision: 2744
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-extensions&revision=2744
Author: campbellbarton
Date: 2011-12-06 17:40:39 +0000 (Tue, 06 Dec 2011)
Log Message:
-----------
minor edits
- remove check if sensor width exists for chan files
- tag nuke chan files to be pep8
- remove unused import
Modified Paths:
--------------
trunk/py/scripts/addons/add_mesh_extra_objects/add_mesh_pyramid.py
trunk/py/scripts/addons/io_anim_nuke_chan/__init__.py
trunk/py/scripts/addons/io_anim_nuke_chan/export_nuke_chan.py
trunk/py/scripts/addons/io_anim_nuke_chan/import_nuke_chan.py
trunk/py/scripts/addons/modules/misc_utils.py
Modified: trunk/py/scripts/addons/add_mesh_extra_objects/add_mesh_pyramid.py
===================================================================
--- trunk/py/scripts/addons/add_mesh_extra_objects/add_mesh_pyramid.py 2011-12-06 13:38:12 UTC (rev 2743)
+++ trunk/py/scripts/addons/add_mesh_extra_objects/add_mesh_pyramid.py 2011-12-06 17:40:39 UTC (rev 2744)
@@ -32,13 +32,9 @@
import bpy
-from bpy.props import (FloatVectorProperty,
- IntProperty,
- FloatProperty,
- BoolProperty)
+from bpy.props import IntProperty, FloatProperty
from add_utils import AddObjectHelper, add_object_data
-from mathutils import Vector
def makePyramid(initial_size, step_height, step_width, number_steps):
Modified: trunk/py/scripts/addons/io_anim_nuke_chan/__init__.py
===================================================================
--- trunk/py/scripts/addons/io_anim_nuke_chan/__init__.py 2011-12-06 13:38:12 UTC (rev 2743)
+++ trunk/py/scripts/addons/io_anim_nuke_chan/__init__.py 2011-12-06 17:40:39 UTC (rev 2744)
@@ -16,6 +16,8 @@
#
# ##### END GPL LICENSE BLOCK #####
+# <pep8-80 compliant>
+
bl_info = {
"name": "Nuke Animation Format (.chan)",
"author": "Michael Krupa",
@@ -50,7 +52,7 @@
EnumProperty)
# property shared by both operators
-rot_ord = EnumProperty(
+rotation_order = EnumProperty(
name="Rotation order",
description="Choose the export rotation order",
items=(('XYZ', "XYZ", "XYZ"),
@@ -73,7 +75,7 @@
filter_glob = StringProperty(default="*.chan", options={'HIDDEN'})
- rot_ord = rot_ord
+ rotation_order = rotation_order
z_up = BoolProperty(
name="Make Z up",
description="Switch the Y and Z axis",
@@ -88,7 +90,7 @@
return import_nuke_chan.read_chan(context,
self.filepath,
self.z_up,
- self.rot_ord)
+ self.rotation_order)
class ExportChan(Operator, ExportHelper):
@@ -103,7 +105,7 @@
name="Make Y up",
description="Switch the Y and Z axis",
default=True)
- rot_ord = rot_ord
+ rotation_order = rotation_order
@classmethod
def poll(cls, context):
@@ -114,7 +116,7 @@
return export_nuke_chan.save_chan(context,
self.filepath,
self.y_up,
- self.rot_ord)
+ self.rotation_order)
def menu_func_import(self, context):
Modified: trunk/py/scripts/addons/io_anim_nuke_chan/export_nuke_chan.py
===================================================================
--- trunk/py/scripts/addons/io_anim_nuke_chan/export_nuke_chan.py 2011-12-06 13:38:12 UTC (rev 2743)
+++ trunk/py/scripts/addons/io_anim_nuke_chan/export_nuke_chan.py 2011-12-06 17:40:39 UTC (rev 2744)
@@ -16,6 +16,8 @@
#
# ##### END GPL LICENSE BLOCK #####
+# <pep8-80 compliant>
+
""" This script is an exporter to the nuke's .chan files.
It takes the currently active object and writes it's transformation data
into a text file with .chan extension."""
@@ -29,6 +31,7 @@
# get the active scene and object
scene = context.scene
obj = context.active_object
+ camera = obj.data if obj.type == 'CAMERA' else None
# get the range of an animation
f_start = scene.frame_start
@@ -72,28 +75,21 @@
fw("%f\t%f\t%f\t" % (degrees(r[0]), degrees(r[1]), degrees(r[2])))
# if we have a camera, add the focal length
- if obj.type == 'CAMERA':
- sensor_x = 0
- sensor_y = 0
- if hasattr(obj.data, "sensor_width"): # Preserve compatibility
- if obj.data.sensor_fit == 'VERTICAL':
- sensor_x = obj.data.sensor_width
- sensor_y = obj.data.sensor_height
- else:
- sensor_x = obj.data.sensor_width
- sensor_y = sensor_x * res_ratio
+ if camera:
+ if camera.sensor_fit == 'VERTICAL':
+ sensor_x = camera.sensor_width
+ sensor_y = camera.sensor_height
else:
- sensor_x = 32 # standard blender's sensor size
+ sensor_x = camera.sensor_width
sensor_y = sensor_x * res_ratio
+ cam_lens = camera.lens
- cam_lens = obj.data.lens
-
# calculate the vertical field of view
# we know the vertical size of (virtual) sensor, the focal length
# of the camera so all we need to do is to feed this data to
- # atan2 function whitch returns the degree (in radians) of
+ # atan2 function whitch returns the degree (in radians) of
# an angle formed by a triangle with two legs of a given lengths
- vfov = degrees(atan2(sensor_y / 2, cam_lens))*2
+ vfov = degrees(atan2(sensor_y / 2, cam_lens)) * 2.0
fw("%f" % vfov)
fw("\n")
Modified: trunk/py/scripts/addons/io_anim_nuke_chan/import_nuke_chan.py
===================================================================
--- trunk/py/scripts/addons/io_anim_nuke_chan/import_nuke_chan.py 2011-12-06 13:38:12 UTC (rev 2743)
+++ trunk/py/scripts/addons/io_anim_nuke_chan/import_nuke_chan.py 2011-12-06 17:40:39 UTC (rev 2744)
@@ -16,6 +16,8 @@
#
# ##### END GPL LICENSE BLOCK #####
+# <pep8-80 compliant>
+
""" This script is an importer for the nuke's .chan files"""
from mathutils import Vector, Matrix, Euler
@@ -27,6 +29,7 @@
# get the active object
scene = context.scene
obj = context.active_object
+ camera = obj.data if obj.type == 'CAMERA' else None
# get the resolution (needed to calculate the camera lens)
res_x = scene.render.resolution_x
@@ -104,23 +107,17 @@
# check if the object is camera and fov data is present
- if obj.type == 'CAMERA' and len(data) > 7:
+ if camera and len(data) > 7:
v_fov = float(data[7])
- sensor_x = 0
- sensor_y = 0
- if hasattr(obj.data, "sensor_width"): # Preserve compatibility
- if obj.data.sensor_fit == 'VERTICAL':
- sensor_x = obj.data.sensor_width
- sensor_y = obj.data.sensor_height
- else:
- sensor_x = obj.data.sensor_width
- sensor_y = sensor_x * res_ratio
+ if camera.sensor_fit == 'VERTICAL':
+ sensor_x = camera.sensor_width
+ sensor_y = camera.sensor_height
else:
- sensor_x = 32 # standard blender's sensor size
+ sensor_x = camera.sensor_width
sensor_y = sensor_x * res_ratio
- lenslen = ((sensor_y / 2.0) / tan(radians(v_fov / 2.0)))
- obj.data.lens = lenslen
- obj.data.keyframe_insert("lens")
+
+ camera.lens = ((sensor_y / 2.0) / tan(radians(v_fov / 2.0)))
+ camera.keyframe_insert("lens")
filehandle.close()
return {'FINISHED'}
Modified: trunk/py/scripts/addons/modules/misc_utils.py
===================================================================
--- trunk/py/scripts/addons/modules/misc_utils.py 2011-12-06 13:38:12 UTC (rev 2743)
+++ trunk/py/scripts/addons/modules/misc_utils.py 2011-12-06 17:40:39 UTC (rev 2744)
@@ -22,18 +22,13 @@
Miscellaneous helper methods.
-
-
'''
-
-
import bpy
from cursor_utils import *
from mathutils import Vector, Matrix
-
class BlenderFake:
@classmethod
@@ -47,7 +42,6 @@
CursorAccess.setCursor(CursorAccess.getCursor())
-
# Converts 3D coordinates in a 3DRegion
# into 2D screen coordinates for that region.
# Borrowed from Buerbaum Martin (Pontiac)
More information about the Bf-extensions-cvs
mailing list