[Bf-extensions-cvs] SVN commit: /data/svn/bf-extensions [2216] trunk/py/scripts/addons/ io_scene_fbx/export_fbx.py: file.write -> fw

Campbell Barton ideasman42 at gmail.com
Wed Aug 3 06:52:30 CEST 2011


Revision: 2216
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-extensions&revision=2216
Author:   campbellbarton
Date:     2011-08-03 04:52:28 +0000 (Wed, 03 Aug 2011)
Log Message:
-----------
file.write -> fw
gives a few % speedup

Modified Paths:
--------------
    trunk/py/scripts/addons/io_scene_fbx/export_fbx.py

Modified: trunk/py/scripts/addons/io_scene_fbx/export_fbx.py
===================================================================
--- trunk/py/scripts/addons/io_scene_fbx/export_fbx.py	2011-08-02 17:26:21 UTC (rev 2215)
+++ trunk/py/scripts/addons/io_scene_fbx/export_fbx.py	2011-08-03 04:52:28 UTC (rev 2216)
@@ -400,17 +400,20 @@
         operator.report({'ERROR'}, "Could'nt open file %r" % filepath)
         return {'CANCELLED'}
 
+    # convenience
+    fw = file.write
+
     # scene = context.scene  # now passed as an arg instead of context
     world = scene.world
 
     # ---------------------------- Write the header first
-    file.write(header_comment)
+    fw(header_comment)
     if use_metadata:
         curtime = time.localtime()[0:6]
     else:
         curtime = (0, 0, 0, 0, 0, 0)
     #
-    file.write(\
+    fw(
 '''FBXHeaderExtension:  {
 	FBXHeaderVersion: 1003
 	FBXVersion: 6100
@@ -430,8 +433,8 @@
 	}
 }''' % (curtime))
 
-    file.write('\nCreationTime: "%.4i-%.2i-%.2i %.2i:%.2i:%.2i:000"' % curtime)
-    file.write('\nCreator: "Blender version %s"' % bpy.app.version_string)
+    fw('\nCreationTime: "%.4i-%.2i-%.2i %.2i:%.2i:%.2i:000"' % curtime)
+    fw('\nCreator: "Blender version %s"' % bpy.app.version_string)
 
     pose_items = []  # list of (fbxName, matrix) to write pose data for, easier to collect allong the way
 
@@ -504,9 +507,9 @@
         '''
         loc, rot, scale, matrix, matrix_rot = object_tx(ob, loc, matrix, matrix_mod)
 
-        file.write('\n\t\t\tProperty: "Lcl Translation", "Lcl Translation", "A+",%.15f,%.15f,%.15f' % loc)
-        file.write('\n\t\t\tProperty: "Lcl Rotation", "Lcl Rotation", "A+",%.15f,%.15f,%.15f' % tuple_rad_to_deg(rot))
-        file.write('\n\t\t\tProperty: "Lcl Scaling", "Lcl Scaling", "A+",%.15f,%.15f,%.15f' % scale)
+        fw('\n\t\t\tProperty: "Lcl Translation", "Lcl Translation", "A+",%.15f,%.15f,%.15f' % loc)
+        fw('\n\t\t\tProperty: "Lcl Rotation", "Lcl Rotation", "A+",%.15f,%.15f,%.15f' % tuple_rad_to_deg(rot))
+        fw('\n\t\t\tProperty: "Lcl Scaling", "Lcl Scaling", "A+",%.15f,%.15f,%.15f' % scale)
         return loc, rot, scale, matrix, matrix_rot
 
     def get_constraints(ob=None):
@@ -552,7 +555,7 @@
 
         # if the type is 0 its an empty otherwise its a mesh
         # only difference at the moment is one has a color
-        file.write('''
+        fw('''
 		Properties60:  {
 			Property: "QuaternionInterpolate", "bool", "",0
 			Property: "Visibility", "Visibility", "A+",1''')
@@ -568,131 +571,131 @@
         # eEULER_ZXY
         # eEULER_ZYX
 
-        file.write('\n\t\t\tProperty: "RotationOffset", "Vector3D", "",0,0,0'
-                   '\n\t\t\tProperty: "RotationPivot", "Vector3D", "",0,0,0'
-                   '\n\t\t\tProperty: "ScalingOffset", "Vector3D", "",0,0,0'
-                   '\n\t\t\tProperty: "ScalingPivot", "Vector3D", "",0,0,0'
-                   '\n\t\t\tProperty: "TranslationActive", "bool", "",0'
-                   )
+        fw('\n\t\t\tProperty: "RotationOffset", "Vector3D", "",0,0,0'
+           '\n\t\t\tProperty: "RotationPivot", "Vector3D", "",0,0,0'
+           '\n\t\t\tProperty: "ScalingOffset", "Vector3D", "",0,0,0'
+           '\n\t\t\tProperty: "ScalingPivot", "Vector3D", "",0,0,0'
+           '\n\t\t\tProperty: "TranslationActive", "bool", "",0'
+           )
 
-        file.write('\n\t\t\tProperty: "TranslationMin", "Vector3D", "",%.15g,%.15g,%.15g' % constraints["loc_min"])
-        file.write('\n\t\t\tProperty: "TranslationMax", "Vector3D", "",%.15g,%.15g,%.15g' % constraints["loc_max"])
-        file.write('\n\t\t\tProperty: "TranslationMinX", "bool", "",%d' % constraints["loc_limit"][0])
-        file.write('\n\t\t\tProperty: "TranslationMinY", "bool", "",%d' % constraints["loc_limit"][1])
-        file.write('\n\t\t\tProperty: "TranslationMinZ", "bool", "",%d' % constraints["loc_limit"][2])
-        file.write('\n\t\t\tProperty: "TranslationMaxX", "bool", "",%d' % constraints["loc_limit"][3])
-        file.write('\n\t\t\tProperty: "TranslationMaxY", "bool", "",%d' % constraints["loc_limit"][4])
-        file.write('\n\t\t\tProperty: "TranslationMaxZ", "bool", "",%d' % constraints["loc_limit"][5])
+        fw('\n\t\t\tProperty: "TranslationMin", "Vector3D", "",%.15g,%.15g,%.15g' % constraints["loc_min"])
+        fw('\n\t\t\tProperty: "TranslationMax", "Vector3D", "",%.15g,%.15g,%.15g' % constraints["loc_max"])
+        fw('\n\t\t\tProperty: "TranslationMinX", "bool", "",%d' % constraints["loc_limit"][0])
+        fw('\n\t\t\tProperty: "TranslationMinY", "bool", "",%d' % constraints["loc_limit"][1])
+        fw('\n\t\t\tProperty: "TranslationMinZ", "bool", "",%d' % constraints["loc_limit"][2])
+        fw('\n\t\t\tProperty: "TranslationMaxX", "bool", "",%d' % constraints["loc_limit"][3])
+        fw('\n\t\t\tProperty: "TranslationMaxY", "bool", "",%d' % constraints["loc_limit"][4])
+        fw('\n\t\t\tProperty: "TranslationMaxZ", "bool", "",%d' % constraints["loc_limit"][5])
 
-        file.write('\n\t\t\tProperty: "RotationOrder", "enum", "",0'
-                   '\n\t\t\tProperty: "RotationSpaceForLimitOnly", "bool", "",0'
-                   '\n\t\t\tProperty: "AxisLen", "double", "",10'
-                   '\n\t\t\tProperty: "PreRotation", "Vector3D", "",0,0,0'
-                   '\n\t\t\tProperty: "PostRotation", "Vector3D", "",0,0,0'
-                   '\n\t\t\tProperty: "RotationActive", "bool", "",0'
-                   )
+        fw('\n\t\t\tProperty: "RotationOrder", "enum", "",0'
+           '\n\t\t\tProperty: "RotationSpaceForLimitOnly", "bool", "",0'
+           '\n\t\t\tProperty: "AxisLen", "double", "",10'
+           '\n\t\t\tProperty: "PreRotation", "Vector3D", "",0,0,0'
+           '\n\t\t\tProperty: "PostRotation", "Vector3D", "",0,0,0'
+           '\n\t\t\tProperty: "RotationActive", "bool", "",0'
+           )
 
-        file.write('\n\t\t\tProperty: "RotationMin", "Vector3D", "",%.15g,%.15g,%.15g' % constraints["rot_min"])
-        file.write('\n\t\t\tProperty: "RotationMax", "Vector3D", "",%.15g,%.15g,%.15g' % constraints["rot_max"])
-        file.write('\n\t\t\tProperty: "RotationMinX", "bool", "",%d' % constraints["rot_limit"][0])
-        file.write('\n\t\t\tProperty: "RotationMinY", "bool", "",%d' % constraints["rot_limit"][1])
-        file.write('\n\t\t\tProperty: "RotationMinZ", "bool", "",%d' % constraints["rot_limit"][2])
-        file.write('\n\t\t\tProperty: "RotationMaxX", "bool", "",%d' % constraints["rot_limit"][0])
-        file.write('\n\t\t\tProperty: "RotationMaxY", "bool", "",%d' % constraints["rot_limit"][1])
-        file.write('\n\t\t\tProperty: "RotationMaxZ", "bool", "",%d' % constraints["rot_limit"][2])
+        fw('\n\t\t\tProperty: "RotationMin", "Vector3D", "",%.15g,%.15g,%.15g' % constraints["rot_min"])
+        fw('\n\t\t\tProperty: "RotationMax", "Vector3D", "",%.15g,%.15g,%.15g' % constraints["rot_max"])
+        fw('\n\t\t\tProperty: "RotationMinX", "bool", "",%d' % constraints["rot_limit"][0])
+        fw('\n\t\t\tProperty: "RotationMinY", "bool", "",%d' % constraints["rot_limit"][1])
+        fw('\n\t\t\tProperty: "RotationMinZ", "bool", "",%d' % constraints["rot_limit"][2])
+        fw('\n\t\t\tProperty: "RotationMaxX", "bool", "",%d' % constraints["rot_limit"][0])
+        fw('\n\t\t\tProperty: "RotationMaxY", "bool", "",%d' % constraints["rot_limit"][1])
+        fw('\n\t\t\tProperty: "RotationMaxZ", "bool", "",%d' % constraints["rot_limit"][2])
 
-        file.write('\n\t\t\tProperty: "RotationStiffnessX", "double", "",0'
-                   '\n\t\t\tProperty: "RotationStiffnessY", "double", "",0'
-                   '\n\t\t\tProperty: "RotationStiffnessZ", "double", "",0'
-                   '\n\t\t\tProperty: "MinDampRangeX", "double", "",0'
-                   '\n\t\t\tProperty: "MinDampRangeY", "double", "",0'
-                   '\n\t\t\tProperty: "MinDampRangeZ", "double", "",0'
-                   '\n\t\t\tProperty: "MaxDampRangeX", "double", "",0'
-                   '\n\t\t\tProperty: "MaxDampRangeY", "double", "",0'
-                   '\n\t\t\tProperty: "MaxDampRangeZ", "double", "",0'
-                   '\n\t\t\tProperty: "MinDampStrengthX", "double", "",0'
-                   '\n\t\t\tProperty: "MinDampStrengthY", "double", "",0'
-                   '\n\t\t\tProperty: "MinDampStrengthZ", "double", "",0'
-                   '\n\t\t\tProperty: "MaxDampStrengthX", "double", "",0'
-                   '\n\t\t\tProperty: "MaxDampStrengthY", "double", "",0'
-                   '\n\t\t\tProperty: "MaxDampStrengthZ", "double", "",0'
-                   '\n\t\t\tProperty: "PreferedAngleX", "double", "",0'
-                   '\n\t\t\tProperty: "PreferedAngleY", "double", "",0'
-                   '\n\t\t\tProperty: "PreferedAngleZ", "double", "",0'
-                   '\n\t\t\tProperty: "InheritType", "enum", "",0'
-                   '\n\t\t\tProperty: "ScalingActive", "bool", "",0'
-                   )
+        fw('\n\t\t\tProperty: "RotationStiffnessX", "double", "",0'
+           '\n\t\t\tProperty: "RotationStiffnessY", "double", "",0'
+           '\n\t\t\tProperty: "RotationStiffnessZ", "double", "",0'
+           '\n\t\t\tProperty: "MinDampRangeX", "double", "",0'
+           '\n\t\t\tProperty: "MinDampRangeY", "double", "",0'
+           '\n\t\t\tProperty: "MinDampRangeZ", "double", "",0'
+           '\n\t\t\tProperty: "MaxDampRangeX", "double", "",0'
+           '\n\t\t\tProperty: "MaxDampRangeY", "double", "",0'
+           '\n\t\t\tProperty: "MaxDampRangeZ", "double", "",0'
+           '\n\t\t\tProperty: "MinDampStrengthX", "double", "",0'
+           '\n\t\t\tProperty: "MinDampStrengthY", "double", "",0'
+           '\n\t\t\tProperty: "MinDampStrengthZ", "double", "",0'
+           '\n\t\t\tProperty: "MaxDampStrengthX", "double", "",0'
+           '\n\t\t\tProperty: "MaxDampStrengthY", "double", "",0'
+           '\n\t\t\tProperty: "MaxDampStrengthZ", "double", "",0'
+           '\n\t\t\tProperty: "PreferedAngleX", "double", "",0'
+           '\n\t\t\tProperty: "PreferedAngleY", "double", "",0'
+           '\n\t\t\tProperty: "PreferedAngleZ", "double", "",0'
+           '\n\t\t\tProperty: "InheritType", "enum", "",0'
+           '\n\t\t\tProperty: "ScalingActive", "bool", "",0'
+           )
 

@@ Diff output truncated at 10240 characters. @@


More information about the Bf-extensions-cvs mailing list