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
This commit is contained in:
Campbell Barton 2009-11-04 18:35:32 +00:00
parent fe82c2674e
commit 51943096a9
7 changed files with 160 additions and 136 deletions

@ -1109,7 +1109,7 @@ def save_3ds(filename, context):
# Blender.Draw.PupMenu("Error%t|This script requires a full python installation") # Blender.Draw.PupMenu("Error%t|This script requires a full python installation")
# # save_3ds('/test_b.3ds') # # save_3ds('/test_b.3ds')
from bpy.props import * from bpy.props import *
class EXPORT_OT_autodesk_3ds(bpy.types.Operator): class Export3DS(bpy.types.Operator):
'''Export to 3DS file format (.3ds).''' '''Export to 3DS file format (.3ds).'''
bl_idname = "export.autodesk_3ds" bl_idname = "export.autodesk_3ds"
bl_label = 'Export 3DS' bl_label = 'Export 3DS'
@ -1135,9 +1135,13 @@ class EXPORT_OT_autodesk_3ds(bpy.types.Operator):
print("Poll") print("Poll")
return context.active_object != None return context.active_object != None
bpy.ops.add(EXPORT_OT_autodesk_3ds) bpy.ops.add(Export3DS)
# Add to a menu # Add to a menu
import dynamic_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) menu_item = dynamic_menu.add(bpy.types.INFO_MT_file_export, menu_func)

@ -3351,7 +3351,7 @@ def write_ui():
# GLOBALS.clear() # GLOBALS.clear()
from bpy.props import * from bpy.props import *
class EXPORT_OT_fbx(bpy.types.Operator): class ExportFBX(bpy.types.Operator):
'''Selection to an ASCII Autodesk FBX''' '''Selection to an ASCII Autodesk FBX'''
bl_idname = "export.fbx" bl_idname = "export.fbx"
bl_label = "Export FBX" bl_label = "Export FBX"
@ -3433,7 +3433,7 @@ class EXPORT_OT_fbx(bpy.types.Operator):
return ('RUNNING_MODAL',) return ('RUNNING_MODAL',)
bpy.ops.add(EXPORT_OT_fbx) bpy.ops.add(ExportFBX)
# if __name__ == "__main__": # if __name__ == "__main__":
# bpy.ops.EXPORT_OT_ply(filename="/tmp/test.ply") # bpy.ops.EXPORT_OT_ply(filename="/tmp/test.ply")
@ -3464,6 +3464,10 @@ bpy.ops.add(EXPORT_OT_fbx)
# Add to a menu # Add to a menu
import dynamic_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) menu_item = dynamic_menu.add(bpy.types.INFO_MT_file_export, menu_func)

@ -78,18 +78,15 @@ def check_vertcount(mesh,vertcount):
def write(filename, sce, ob, PREF_STARTFRAME, PREF_ENDFRAME, PREF_FPS): 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 = Mesh.New()
mesh_orig.getFromObject(ob.name) mesh_orig.getFromObject(ob.name)
""" """
bpy.ops.object.mode_set(mode='OBJECT')
orig_frame = sce.current_frame orig_frame = sce.current_frame
sce.set_frame(PREF_STARTFRAME) sce.set_frame(PREF_STARTFRAME)
me = ob.create_mesh(True, 'PREVIEW') me = ob.create_mesh(True, 'PREVIEW')
@ -152,7 +149,7 @@ def write(filename, sce, ob, PREF_STARTFRAME, PREF_ENDFRAME, PREF_FPS):
from bpy.props import * from bpy.props import *
class EXPORT_OT_mdd(bpy.types.Operator): class ExportMDD(bpy.types.Operator):
'''Animated mesh to MDD vertex keyframe file.''' '''Animated mesh to MDD vertex keyframe file.'''
bl_idname = "export.mdd" bl_idname = "export.mdd"
bl_label = "Export MDD" bl_label = "Export MDD"
@ -173,7 +170,8 @@ class EXPORT_OT_mdd(bpy.types.Operator):
end_frame = IntProperty(name="End Frame", description="End frame for baking", min=minframe, max=maxframe, default= 250) end_frame = IntProperty(name="End Frame", description="End frame for baking", min=minframe, max=maxframe, default= 250)
def poll(self, context): def poll(self, context):
return context.active_object != None ob = context.active_object
return (ob and ob.type=='MESH')
def execute(self, context): def execute(self, context):
if not self.path: if not self.path:
@ -187,15 +185,17 @@ class EXPORT_OT_mdd(bpy.types.Operator):
wm.add_fileselect(self) wm.add_fileselect(self)
return ('RUNNING_MODAL',) return ('RUNNING_MODAL',)
bpy.ops.add(EXPORT_OT_mdd) bpy.ops.add(ExportMDD)
# Add to a menu # Add to a menu
import dynamic_menu import dynamic_menu
menu_func = lambda self, context: self.layout.itemO("export.mdd", text="Vertex Keyframe Animation (.mdd)...")
def menu_func(self, context):
default_path = bpy.data.filename.replace(".blend", ".mdd")
self.layout.item_stringO(ExportMDD.bl_idname, "path", default_path, text="Vertex Keyframe Animation (.mdd)...")
menu_item = dynamic_menu.add(bpy.types.INFO_MT_file_export, menu_func) menu_item = dynamic_menu.add(bpy.types.INFO_MT_file_export, menu_func)
if __name__=='__main__': if __name__=='__main__':
#if not pack:
# Draw.PupMenu('Error%t|This script requires a full python install')
#Blender.Window.FileSelector(mdd_export_ui, 'EXPORT MDD', sys.makename(ext='.mdd')) #Blender.Window.FileSelector(mdd_export_ui, 'EXPORT MDD', sys.makename(ext='.mdd'))
bpy.ops.EXPORT_OT_mdd(path="/tmp/test.mdd") bpy.ops.EXPORT_OT_mdd(path="/tmp/test.mdd")

@ -932,7 +932,7 @@ Currently the exporter lacks these features:
from bpy.props import * from bpy.props import *
class EXPORT_OT_obj(bpy.types.Operator): class ExportOBJ(bpy.types.Operator):
'''Save a Wavefront OBJ File''' '''Save a Wavefront OBJ File'''
bl_idname = "export.obj" bl_idname = "export.obj"
@ -1002,10 +1002,14 @@ class EXPORT_OT_obj(bpy.types.Operator):
print("Poll") print("Poll")
return context.active_object != None return context.active_object != None
bpy.ops.add(EXPORT_OT_obj) bpy.ops.add(ExportOBJ)
import dynamic_menu import dynamic_menu
menu_func = lambda self, context: self.layout.itemO("export.obj", text="Wavefront (.obj)...")
def menu_func(self, context):
default_path = bpy.data.filename.replace(".blend", ".obj")
self.layout.item_stringO(ExportOBJ.bl_idname, "path", default_path, text="Wavefront (.obj)...")
menu_item = dynamic_menu.add(bpy.types.INFO_MT_file_export, menu_func) menu_item = dynamic_menu.add(bpy.types.INFO_MT_file_export, menu_func)
if __name__ == "__main__": if __name__ == "__main__":

@ -252,7 +252,7 @@ def write(filename, scene, ob, \
from bpy.props import * from bpy.props import *
class EXPORT_OT_ply(bpy.types.Operator): class ExportPLY(bpy.types.Operator):
'''Export a single object as a stanford PLY with normals, colours and texture coordinates.''' '''Export a single object as a stanford PLY with normals, colours and texture coordinates.'''
bl_idname = "export.ply" bl_idname = "export.ply"
bl_label = "Export PLY" bl_label = "Export PLY"
@ -292,10 +292,14 @@ class EXPORT_OT_ply(bpy.types.Operator):
return ('RUNNING_MODAL',) return ('RUNNING_MODAL',)
bpy.ops.add(EXPORT_OT_ply) bpy.ops.add(ExportPLY)
import dynamic_menu import dynamic_menu
menu_func = lambda self, context: self.layout.itemO("export.ply", text="Stanford (.ply)...")
def menu_func(self, context):
default_path = bpy.data.filename.replace(".blend", ".ply")
self.layout.item_stringO(ExportPLY.bl_idname, "path", default_path, text="Stanford (.ply)...")
menu_item = dynamic_menu.add(bpy.types.INFO_MT_file_export, menu_func) menu_item = dynamic_menu.add(bpy.types.INFO_MT_file_export, menu_func)
if __name__ == "__main__": if __name__ == "__main__":

@ -1215,7 +1215,7 @@ def x3d_export_ui(filename):
from bpy.props import * from bpy.props import *
class EXPORT_OT_x3d(bpy.types.Operator): class ExportX3D(bpy.types.Operator):
'''Export selection to Extensible 3D file (.x3d)''' '''Export selection to Extensible 3D file (.x3d)'''
bl_idname = "export.x3d" bl_idname = "export.x3d"
bl_label = 'Export X3D' bl_label = 'Export X3D'
@ -1238,10 +1238,14 @@ class EXPORT_OT_x3d(bpy.types.Operator):
wm.add_fileselect(self) wm.add_fileselect(self)
return ('RUNNING_MODAL',) return ('RUNNING_MODAL',)
bpy.ops.add(EXPORT_OT_x3d) bpy.ops.add(ExportX3D)
import dynamic_menu import dynamic_menu
menu_func = lambda self, context: self.layout.itemO("export.x3d", text="X3D Extensible 3D (.x3d)...")
def menu_func(self, context):
default_path = bpy.data.filename.replace(".blend", ".x3d")
self.layout.item_stringO(ExportX3D.bl_idname, "path", default_path, text="X3D Extensible 3D (.x3d)...")
menu_item = dynamic_menu.add(bpy.types.INFO_MT_file_export, menu_func) menu_item = dynamic_menu.add(bpy.types.INFO_MT_file_export, menu_func)
# NOTES # NOTES

@ -170,11 +170,11 @@ def write_func(rna, ident, out, func_type):
# Operators and functions work differently # Operators and functions work differently
if func_type=='OPERATOR': if func_type=='OPERATOR':
rna_func_name = rna_struct.identifier.split("_OT_")[-1] rna_func_name = rna_struct.identifier.split("_OT_")[-1]
rna_func_desc = rna_struct.description.strip().replace('\n', ' ') rna_func_desc = rna_struct.description.strip()
items = rna_struct.properties.items() items = rna_struct.properties.items()
else: else:
rna_func_name = rna.identifier rna_func_name = rna.identifier
rna_func_desc = rna.description.strip().replace('\n', ' ') rna_func_desc = rna.description.strip()
items = rna.parameters.items() items = rna.parameters.items()
@ -288,7 +288,11 @@ def write_func(rna, ident, out, func_type):
out.write(ident+'def %s(%s):\n' % (rna_func_name, ', '.join(kw_args))) out.write(ident+'def %s(%s):\n' % (rna_func_name, ', '.join(kw_args)))
out.write(ident+'\t"""\n') out.write(ident+'\t"""\n')
out.write(ident+'\t%s\n' % rna_func_desc)
# Descriptions could be multiline
for rna_func_desc_line in rna_func_desc.split('\n'):
out.write(ident+'\t%s\n' % rna_func_desc_line.strip())
for desc in kw_arg_attrs: for desc in kw_arg_attrs:
out.write(ident+'\t%s\n' % desc) out.write(ident+'\t%s\n' % desc)