[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [24317] trunk/blender: bugfix [#19804] . MDD is not working?? // Also filetype issue?
Campbell Barton
ideasman42 at gmail.com
Wed Nov 4 19:35:34 CET 2009
Revision: 24317
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=24317
Author: campbellbarton
Date: 2009-11-04 19:35:32 +0100 (Wed, 04 Nov 2009)
Log Message:
-----------
bugfix [#19804] .MDD is not working?? // Also filetype issue?
- made all exporters default to the blend filename with the extension replaced
- MDD's poll function now checks for an active mesh
- multiline docstrings are written as multiline docs when generating epydocs
Modified Paths:
--------------
trunk/blender/release/scripts/io/export_3ds.py
trunk/blender/release/scripts/io/export_fbx.py
trunk/blender/release/scripts/io/export_mdd.py
trunk/blender/release/scripts/io/export_obj.py
trunk/blender/release/scripts/io/export_ply.py
trunk/blender/release/scripts/io/export_x3d.py
trunk/blender/source/blender/python/epy_doc_gen.py
Modified: trunk/blender/release/scripts/io/export_3ds.py
===================================================================
--- trunk/blender/release/scripts/io/export_3ds.py 2009-11-04 17:50:31 UTC (rev 24316)
+++ trunk/blender/release/scripts/io/export_3ds.py 2009-11-04 18:35:32 UTC (rev 24317)
@@ -1109,7 +1109,7 @@
# Blender.Draw.PupMenu("Error%t|This script requires a full python installation")
# # save_3ds('/test_b.3ds')
from bpy.props import *
-class EXPORT_OT_autodesk_3ds(bpy.types.Operator):
+class Export3DS(bpy.types.Operator):
'''Export to 3DS file format (.3ds).'''
bl_idname = "export.autodesk_3ds"
bl_label = 'Export 3DS'
@@ -1135,9 +1135,13 @@
print("Poll")
return context.active_object != None
-bpy.ops.add(EXPORT_OT_autodesk_3ds)
+bpy.ops.add(Export3DS)
# Add to a menu
import dynamic_menu
-menu_func = lambda self, context: self.layout.itemO("export.autodesk_3ds", text="Autodesk 3DS...")
+
+def menu_func(self, context):
+ default_path = bpy.data.filename.replace(".blend", ".3ds")
+ self.layout.item_stringO(Export3DS.bl_idname, "path", default_path, text="Autodesk 3DS...")
+
menu_item = dynamic_menu.add(bpy.types.INFO_MT_file_export, menu_func)
Modified: trunk/blender/release/scripts/io/export_fbx.py
===================================================================
--- trunk/blender/release/scripts/io/export_fbx.py 2009-11-04 17:50:31 UTC (rev 24316)
+++ trunk/blender/release/scripts/io/export_fbx.py 2009-11-04 18:35:32 UTC (rev 24317)
@@ -3351,7 +3351,7 @@
# GLOBALS.clear()
from bpy.props import *
-class EXPORT_OT_fbx(bpy.types.Operator):
+class ExportFBX(bpy.types.Operator):
'''Selection to an ASCII Autodesk FBX'''
bl_idname = "export.fbx"
bl_label = "Export FBX"
@@ -3433,7 +3433,7 @@
return ('RUNNING_MODAL',)
-bpy.ops.add(EXPORT_OT_fbx)
+bpy.ops.add(ExportFBX)
# if __name__ == "__main__":
# bpy.ops.EXPORT_OT_ply(filename="/tmp/test.ply")
@@ -3464,6 +3464,10 @@
# Add to a menu
import dynamic_menu
-menu_func = lambda self, context: self.layout.itemO("export.fbx", text="Autodesk FBX...")
+
+def menu_func(self, context):
+ default_path = bpy.data.filename.replace(".blend", ".fbx")
+ self.layout.item_stringO(ExportFBX.bl_idname, "path", default_path, text="Autodesk FBX...")
+
menu_item = dynamic_menu.add(bpy.types.INFO_MT_file_export, menu_func)
Modified: trunk/blender/release/scripts/io/export_mdd.py
===================================================================
--- trunk/blender/release/scripts/io/export_mdd.py 2009-11-04 17:50:31 UTC (rev 24316)
+++ trunk/blender/release/scripts/io/export_mdd.py 2009-11-04 18:35:32 UTC (rev 24317)
@@ -54,148 +54,148 @@
#from Blender import *
#import BPyMessages
try:
- from struct import pack
+ from struct import pack
except:
- pack = None
+ pack = None
def zero_file(filepath):
- '''
- If a file fails, this replaces it with 1 char, better not remove it?
- '''
- file = open(filepath, 'w')
- file.write('\n') # apparently macosx needs some data in a blank file?
- file.close()
+ '''
+ If a file fails, this replaces it with 1 char, better not remove it?
+ '''
+ file = open(filepath, 'w')
+ file.write('\n') # apparently macosx needs some data in a blank file?
+ file.close()
def check_vertcount(mesh,vertcount):
- '''
- check and make sure the vertcount is consistent throughout the frame range
- '''
- if len(mesh.verts) != vertcount:
- raise Exception('Error, number of verts has changed during animation, cannot export')
- f.close()
- zero_file(filepath)
- return
-
-
+ '''
+ check and make sure the vertcount is consistent throughout the frame range
+ '''
+ if len(mesh.verts) != vertcount:
+ raise Exception('Error, number of verts has changed during animation, cannot export')
+ f.close()
+ zero_file(filepath)
+ return
+
+
def write(filename, sce, ob, PREF_STARTFRAME, PREF_ENDFRAME, PREF_FPS):
- if not pack:
- raise Exception('Error, this script requires the "pack" module')
-
- if ob.type != 'MESH':
- raise Exception('Error, active object is not a mesh')
- """
- Window.EditMode(0)
- Blender.Window.WaitCursor(1)
+ """
+ Blender.Window.WaitCursor(1)
- mesh_orig = Mesh.New()
- mesh_orig.getFromObject(ob.name)
- """
- orig_frame = sce.current_frame
- sce.set_frame(PREF_STARTFRAME)
- me = ob.create_mesh(True, 'PREVIEW')
+ mesh_orig = Mesh.New()
+ mesh_orig.getFromObject(ob.name)
+ """
- #Flip y and z
- mat_flip= Mathutils.Matrix(\
- [1.0, 0.0, 0.0, 0.0],\
- [0.0, 0.0, 1.0, 0.0],\
- [0.0, 1.0, 0.0, 0.0],\
- [0.0, 0.0, 0.0, 1.0],\
- )
+ bpy.ops.object.mode_set(mode='OBJECT')
- numverts = len(me.verts)
+ orig_frame = sce.current_frame
+ sce.set_frame(PREF_STARTFRAME)
+ me = ob.create_mesh(True, 'PREVIEW')
- numframes = PREF_ENDFRAME-PREF_STARTFRAME+1
- PREF_FPS= float(PREF_FPS)
- f = open(filename, 'wb') #no Errors yet:Safe to create file
-
- # Write the header
- f.write(pack(">2i", numframes, numverts))
-
- # Write the frame times (should we use the time IPO??)
- f.write( pack(">%df" % (numframes), *[frame/PREF_FPS for frame in range(numframes)]) ) # seconds
-
- #rest frame needed to keep frames in sync
- """
- Blender.Set('curframe', PREF_STARTFRAME)
- me_tmp.getFromObject(ob.name)
- """
+ #Flip y and z
+ mat_flip= Mathutils.Matrix(\
+ [1.0, 0.0, 0.0, 0.0],\
+ [0.0, 0.0, 1.0, 0.0],\
+ [0.0, 1.0, 0.0, 0.0],\
+ [0.0, 0.0, 0.0, 1.0],\
+ )
- check_vertcount(me,numverts)
- me.transform(mat_flip * ob.matrix)
- f.write(pack(">%df" % (numverts*3), *[axis for v in me.verts for axis in v.co]))
-
- for frame in range(PREF_STARTFRAME,PREF_ENDFRAME+1):#in order to start at desired frame
- """
- Blender.Set('curframe', frame)
- me_tmp.getFromObject(ob.name)
- """
+ numverts = len(me.verts)
- sce.set_frame(frame)
- me = ob.create_mesh(True, 'PREVIEW')
- check_vertcount(me,numverts)
- me.transform(mat_flip * ob.matrix)
-
- # Write the vertex data
- f.write(pack(">%df" % (numverts*3), *[axis for v in me.verts for axis in v.co]))
-
- """
- me_tmp.verts= None
- """
- f.close()
-
- print ('MDD Exported: %s frames:%d\n'% (filename, numframes-1))
- """
- Blender.Window.WaitCursor(0)
- Blender.Set('curframe', orig_frame)
- """
- sce.set_frame(orig_frame)
+ numframes = PREF_ENDFRAME-PREF_STARTFRAME+1
+ PREF_FPS= float(PREF_FPS)
+ f = open(filename, 'wb') #no Errors yet:Safe to create file
+
+ # Write the header
+ f.write(pack(">2i", numframes, numverts))
+
+ # Write the frame times (should we use the time IPO??)
+ f.write( pack(">%df" % (numframes), *[frame/PREF_FPS for frame in range(numframes)]) ) # seconds
+
+ #rest frame needed to keep frames in sync
+ """
+ Blender.Set('curframe', PREF_STARTFRAME)
+ me_tmp.getFromObject(ob.name)
+ """
+ check_vertcount(me,numverts)
+ me.transform(mat_flip * ob.matrix)
+ f.write(pack(">%df" % (numverts*3), *[axis for v in me.verts for axis in v.co]))
+
+ for frame in range(PREF_STARTFRAME,PREF_ENDFRAME+1):#in order to start at desired frame
+ """
+ Blender.Set('curframe', frame)
+ me_tmp.getFromObject(ob.name)
+ """
+
+ sce.set_frame(frame)
+ me = ob.create_mesh(True, 'PREVIEW')
+ check_vertcount(me,numverts)
+ me.transform(mat_flip * ob.matrix)
+
+ # Write the vertex data
+ f.write(pack(">%df" % (numverts*3), *[axis for v in me.verts for axis in v.co]))
+
+ """
+ me_tmp.verts= None
+ """
+ f.close()
+
+ print ('MDD Exported: %s frames:%d\n'% (filename, numframes-1))
+ """
+ Blender.Window.WaitCursor(0)
+ Blender.Set('curframe', orig_frame)
+ """
+ sce.set_frame(orig_frame)
+
from bpy.props import *
-class EXPORT_OT_mdd(bpy.types.Operator):
- '''Animated mesh to MDD vertex keyframe file.'''
- bl_idname = "export.mdd"
- bl_label = "Export MDD"
+class ExportMDD(bpy.types.Operator):
+ '''Animated mesh to MDD vertex keyframe file.'''
+ bl_idname = "export.mdd"
+ bl_label = "Export MDD"
- # get first scene to get min and max properties for frames, fps
+ # get first scene to get min and max properties for frames, fps
- sce = bpy.data.scenes[bpy.data.scenes.keys()[0]]
- minframe = sce.rna_type.properties["current_frame"].soft_min
- maxframe = sce.rna_type.properties["current_frame"].soft_max
- minfps = sce.render_data.rna_type.properties["fps"].soft_min
- maxfps = sce.render_data.rna_type.properties["fps"].soft_max
+ sce = bpy.data.scenes[bpy.data.scenes.keys()[0]]
+ minframe = sce.rna_type.properties["current_frame"].soft_min
+ maxframe = sce.rna_type.properties["current_frame"].soft_max
+ minfps = sce.render_data.rna_type.properties["fps"].soft_min
+ maxfps = sce.render_data.rna_type.properties["fps"].soft_max
- # List of operator properties, the attributes will be assigned
- # to the class instance from the operator settings before calling.
- path = StringProperty(name="File Path", description="File path used for exporting the MDD file", maxlen= 1024, default= "tmp.mdd")
- fps = IntProperty(name="Frames Per Second", description="Number of frames/second", min=minfps, max=maxfps, default= 25)
- start_frame = IntProperty(name="Start Frame", description="Start frame for baking", min=minframe,max=maxframe,default=1)
- end_frame = IntProperty(name="End Frame", description="End frame for baking", min=minframe, max=maxframe, default= 250)
+ # List of operator properties, the attributes will be assigned
+ # to the class instance from the operator settings before calling.
+ path = StringProperty(name="File Path", description="File path used for exporting the MDD file", maxlen= 1024, default= "tmp.mdd")
+ fps = IntProperty(name="Frames Per Second", description="Number of frames/second", min=minfps, max=maxfps, default= 25)
+ start_frame = IntProperty(name="Start Frame", description="Start frame for baking", min=minframe,max=maxframe,default=1)
+ end_frame = IntProperty(name="End Frame", description="End frame for baking", min=minframe, max=maxframe, default= 250)
- def poll(self, context):
- return context.active_object != None
+ def poll(self, context):
+ ob = context.active_object
+ return (ob and ob.type=='MESH')
- def execute(self, context):
- if not self.path:
- raise Exception("filename not set")
- write(self.path, context.scene, context.active_object,
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list