[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [24198] trunk/blender: define operator properties in the class, similar to django fields

Campbell Barton ideasman42 at gmail.com
Sat Oct 31 17:40:15 CET 2009


Revision: 24198
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=24198
Author:   campbellbarton
Date:     2009-10-31 17:40:14 +0100 (Sat, 31 Oct 2009)

Log Message:
-----------
define operator properties in the class, similar to django fields

# Before
[
	bpy.props.StringProperty(attr="path", name="File Path", description="File path used for exporting the PLY file", maxlen= 1024, default= ""),
	bpy.props.BoolProperty(attr="use_modifiers", name="Apply Modifiers", description="Apply Modifiers to the exported mesh", default= True),
	bpy.props.BoolProperty(attr="use_normals", name="Export Normals", description="Export Normals for smooth and hard shaded faces", default= True),
	bpy.props.BoolProperty(attr="use_uvs", name="Export UVs", description="Exort the active UV layer", default= True),
	bpy.props.BoolProperty(attr="use_colors", name="Export Vertex Colors", description="Exort the active vertex color layer", default= True)
]

# After
path = StringProperty(attr="", name="File Path", description="File path used for exporting the PLY file", maxlen= 1024, default= "")
use_modifiers = BoolProperty(attr="", name="Apply Modifiers", description="Apply Modifiers to the exported mesh", default= True)
use_normals = BoolProperty(attr="", name="Export Normals", description="Export Normals for smooth and hard shaded faces", default= True)
use_uvs = BoolProperty(attr="", name="Export UVs", description="Exort the active UV layer", default= True)
use_colors = BoolProperty(attr="", name="Export Vertex Colors", description="Exort the active vertex color layer", default= True)

Modified Paths:
--------------
    trunk/blender/release/scripts/io/add_mesh_torus.py
    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/release/scripts/io/import_3ds.py
    trunk/blender/release/scripts/io/import_obj.py
    trunk/blender/release/scripts/io/mesh_skin.py
    trunk/blender/release/scripts/io/netrender/operators.py
    trunk/blender/release/scripts/modules/bpy_ops.py
    trunk/blender/release/scripts/templates/operator.py
    trunk/blender/release/scripts/ui/space_userpref.py
    trunk/blender/release/scripts/ui/space_view3d.py
    trunk/blender/source/blender/python/intern/bpy_operator_wrap.c
    trunk/blender/source/blender/python/intern/bpy_rna.c
    trunk/blender/source/blender/python/intern/bpy_rna.h

Modified: trunk/blender/release/scripts/io/add_mesh_torus.py
===================================================================
--- trunk/blender/release/scripts/io/add_mesh_torus.py	2009-10-31 13:31:23 UTC (rev 24197)
+++ trunk/blender/release/scripts/io/add_mesh_torus.py	2009-10-31 16:40:14 UTC (rev 24198)
@@ -46,6 +46,7 @@
 	
 	return verts, faces
 
+from bpy.props import *
 
 class MESH_OT_primitive_torus_add(bpy.types.Operator):
 	'''Add a torus mesh.'''
@@ -53,13 +54,12 @@
 	bl_label = "Add Torus"
 	bl_register = True
 	bl_undo = True
-	bl_props = [
-		bpy.props.FloatProperty(attr="major_radius", name="Major Radius", description="Number of segments for the main ring of the torus", default= 1.0, min= 0.01, max= 100.0),
-		bpy.props.FloatProperty(attr="minor_radius", name="Minor Radius", description="Number of segments for the minor ring of the torus", default= 0.25, min= 0.01, max= 100.0),
-		bpy.props.IntProperty(attr="major_segments", name="Major Segments", description="Number of segments for the main ring of the torus", default= 48, min= 3, max= 256),
-		bpy.props.IntProperty(attr="minor_segments", name="Minor Segments", description="Number of segments for the minor ring of the torus", default= 16, min= 3, max= 256),
-	]
 	
+	major_radius = FloatProperty(attr="", name="Major Radius", description="Number of segments for the main ring of the torus", default= 1.0, min= 0.01, max= 100.0)
+	minor_radius = FloatProperty(name="Minor Radius", description="Number of segments for the minor ring of the torus", default= 0.25, min= 0.01, max= 100.0)
+	major_segments = IntProperty(name="Major Segments", description="Number of segments for the main ring of the torus", default= 48, min= 3, max= 256)
+	minor_segments = IntProperty(name="Minor Segments", description="Number of segments for the minor ring of the torus", default= 16, min= 3, max= 256)
+	
 	def execute(self, context):
 		verts_loc, faces = add_torus(self.major_radius, self.minor_radius, self.major_segments, self.minor_segments)
 		

Modified: trunk/blender/release/scripts/io/export_3ds.py
===================================================================
--- trunk/blender/release/scripts/io/export_3ds.py	2009-10-31 13:31:23 UTC (rev 24197)
+++ trunk/blender/release/scripts/io/export_3ds.py	2009-10-31 16:40:14 UTC (rev 24198)
@@ -1090,7 +1090,7 @@
 #     else:
 #         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):
 	'''Export to 3DS file format (.3ds).'''
 	bl_idname = "export.autodesk_3ds"
@@ -1099,11 +1099,11 @@
 	# List of operator properties, the attributes will be assigned
 	# to the class instance from the operator settings before calling.
 
-	bl_props = [
-		# bpy.props.StringProperty(attr="filename", name="File Name", description="File name used for exporting the 3DS file", maxlen= 1024, default= ""),
-		bpy.props.StringProperty(attr="path", name="File Path", description="File path used for exporting the 3DS file", maxlen= 1024, default= ""),
-	]
 	
+	# filename = bpy.props.StringProperty(attr="", name="File Name", description="File name used for exporting the 3DS file", maxlen= 1024, default= ""),
+	path = StringProperty(name="File Path", description="File path used for exporting the 3DS file", maxlen= 1024, default= "")
+
+	
 	def execute(self, context):
 		save_3ds(self.path, context)
 		return ('FINISHED',)

Modified: trunk/blender/release/scripts/io/export_fbx.py
===================================================================
--- trunk/blender/release/scripts/io/export_fbx.py	2009-10-31 13:31:23 UTC (rev 24197)
+++ trunk/blender/release/scripts/io/export_fbx.py	2009-10-31 16:40:14 UTC (rev 24198)
@@ -3332,7 +3332,7 @@
 	
 	
 	# GLOBALS.clear()
-
+from bpy.props import *
 class EXPORT_OT_fbx(bpy.types.Operator):
 	'''Selection to an ASCII Autodesk FBX'''
 	bl_idname = "export.fbx"
@@ -3341,36 +3341,36 @@
 	# List of operator properties, the attributes will be assigned
 	# to the class instance from the operator settings before calling.
 	
-	bl_props = [
-		bpy.props.StringProperty(attr="path", name="File Path", description="File path used for exporting the FBX file", maxlen= 1024, default= ""),
-		
-		bpy.props.BoolProperty(attr="EXP_OBS_SELECTED", name="Selected Objects", description="Export selected objects on visible layers", default=True),
-# 		bpy.props.BoolProperty(attr="EXP_OBS_SCENE", name="Scene Objects", description="Export all objects in this scene", default=True),
-		bpy.props.FloatProperty(attr="_SCALE", name="Scale", description="Scale all data, (Note! some imports dont support scaled armatures)", min=0.01, max=1000.0, soft_min=0.01, soft_max=1000.0, default=1.0),
-		bpy.props.BoolProperty(attr="_XROT90", name="Rot X90", description="Rotate all objects 90 degrese about the X axis", default=True),
-		bpy.props.BoolProperty(attr="_YROT90", name="Rot Y90", description="Rotate all objects 90 degrese about the Y axis", default=False),
-		bpy.props.BoolProperty(attr="_ZROT90", name="Rot Z90", description="Rotate all objects 90 degrese about the Z axis", default=False),
-		bpy.props.BoolProperty(attr="EXP_EMPTY", name="Empties", description="Export empty objects", default=True),
-		bpy.props.BoolProperty(attr="EXP_CAMERA", name="Cameras", description="Export camera objects", default=True),
-		bpy.props.BoolProperty(attr="EXP_LAMP", name="Lamps", description="Export lamp objects", default=True),
-		bpy.props.BoolProperty(attr="EXP_ARMATURE", name="Armatures", description="Export armature objects", default=True),
-		bpy.props.BoolProperty(attr="EXP_MESH", name="Meshes", description="Export mesh objects", default=True),
-		bpy.props.BoolProperty(attr="EXP_MESH_APPLY_MOD", name="Modifiers", description="Apply modifiers to mesh objects", default=True),
-		bpy.props.BoolProperty(attr="EXP_MESH_HQ_NORMALS", name="HQ Normals", description="Generate high quality normals", default=True),
-		bpy.props.BoolProperty(attr="EXP_IMAGE_COPY", name="Copy Image Files", description="Copy image files to the destination path", default=False),
-		# armature animation
-		bpy.props.BoolProperty(attr="ANIM_ENABLE", name="Enable Animation", description="Export keyframe animation", default=True),
-		bpy.props.BoolProperty(attr="ANIM_OPTIMIZE", name="Optimize Keyframes", description="Remove double keyframes", default=True),
-		bpy.props.FloatProperty(attr="ANIM_OPTIMIZE_PRECISSION", name="Precision", description="Tolerence for comparing double keyframes (higher for greater accuracy)", min=1, max=16, soft_min=1, soft_max=16, default=6.0),
-# 		bpy.props.BoolProperty(attr="ANIM_ACTION_ALL", name="Current Action", description="Use actions currently applied to the armatures (use scene start/end frame)", default=True),
-		bpy.props.BoolProperty(attr="ANIM_ACTION_ALL", name="All Actions", description="Use all actions for armatures, if false, use current action", default=False),
-		# batch
-		bpy.props.BoolProperty(attr="BATCH_ENABLE", name="Enable Batch", description="Automate exporting multiple scenes or groups to files", default=False),
-		bpy.props.BoolProperty(attr="BATCH_GROUP", name="Group > File", description="Export each group as an FBX file, if false, export each scene as an FBX file", default=False),
-		bpy.props.BoolProperty(attr="BATCH_OWN_DIR", name="Own Dir", description="Create a dir for each exported file", default=True),
-		bpy.props.StringProperty(attr="BATCH_FILE_PREFIX", name="Prefix", description="Prefix each file with this name", maxlen= 1024, default=""),
-	]
 	
+	path = StringProperty(name="File Path", description="File path used for exporting the FBX file", maxlen= 1024, default= "")
+	
+	EXP_OBS_SELECTED = BoolProperty(name="Selected Objects", description="Export selected objects on visible layers", default=True)
+# 	EXP_OBS_SCENE = BoolProperty(name="Scene Objects", description="Export all objects in this scene", default=True)
+	_SCALE = FloatProperty(name="Scale", description="Scale all data, (Note! some imports dont support scaled armatures)", min=0.01, max=1000.0, soft_min=0.01, soft_max=1000.0, default=1.0)
+	_XROT90 = BoolProperty(name="Rot X90", description="Rotate all objects 90 degrese about the X axis", default=True)
+	_YROT90 = BoolProperty(name="Rot Y90", description="Rotate all objects 90 degrese about the Y axis", default=False)
+	_ZROT90 = BoolProperty(name="Rot Z90", description="Rotate all objects 90 degrese about the Z axis", default=False)
+	EXP_EMPTY = BoolProperty(name="Empties", description="Export empty objects", default=True)
+	EXP_CAMERA = BoolProperty(name="Cameras", description="Export camera objects", default=True)
+	EXP_LAMP = BoolProperty(name="Lamps", description="Export lamp objects", default=True)
+	EXP_ARMATURE = BoolProperty(name="Armatures", description="Export armature objects", default=True)
+	EXP_MESH = BoolProperty(name="Meshes", description="Export mesh objects", default=True)
+	EXP_MESH_APPLY_MOD = BoolProperty(name="Modifiers", description="Apply modifiers to mesh objects", default=True)
+	EXP_MESH_HQ_NORMALS = BoolProperty(name="HQ Normals", description="Generate high quality normals", default=True)
+	EXP_IMAGE_COPY = BoolProperty(name="Copy Image Files", description="Copy image files to the destination path", default=False)
+	# armature animation
+	ANIM_ENABLE = BoolProperty(name="Enable Animation", description="Export keyframe animation", default=True)
+	ANIM_OPTIMIZE = BoolProperty(name="Optimize Keyframes", description="Remove double keyframes", default=True)
+	ANIM_OPTIMIZE_PRECISSION = FloatProperty(name="Precision", description="Tolerence for comparing double keyframes (higher for greater accuracy)", min=1, max=16, soft_min=1, soft_max=16, default=6.0)
+# 	ANIM_ACTION_ALL = BoolProperty(name="Current Action", description="Use actions currently applied to the armatures (use scene start/end frame)", default=True)
+	ANIM_ACTION_ALL = BoolProperty(name="All Actions", description="Use all actions for armatures, if false, use current action", default=False)
+	# batch
+	BATCH_ENABLE = BoolProperty(name="Enable Batch", description="Automate exporting multiple scenes or groups to files", default=False)

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list