[Bf-extensions-cvs] SVN commit: /data/svn/bf-extensions [3206] contrib/py/scripts/addons/ space_view3d_paint_bprojection.py: BProjection: now , after very hard work, it can save several setting in a list, the workflow will be faster
geo kgeo
kgeogeo at hotmail.com
Wed Apr 4 00:12:42 CEST 2012
Revision: 3206
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-extensions&revision=3206
Author: kgeogeo
Date: 2012-04-03 22:12:24 +0000 (Tue, 03 Apr 2012)
Log Message:
-----------
BProjection: now ,after very hard work, it can save several setting in a list, the workflow will be faster
Modified Paths:
--------------
contrib/py/scripts/addons/space_view3d_paint_bprojection.py
Modified: contrib/py/scripts/addons/space_view3d_paint_bprojection.py
===================================================================
--- contrib/py/scripts/addons/space_view3d_paint_bprojection.py 2012-04-03 10:59:13 UTC (rev 3205)
+++ contrib/py/scripts/addons/space_view3d_paint_bprojection.py 2012-04-03 22:12:24 UTC (rev 3206)
@@ -10,7 +10,7 @@
import bpy
from bpy.types import Panel, Operator
-from bpy.props import IntProperty, FloatProperty, BoolProperty, IntVectorProperty, StringProperty, FloatVectorProperty
+from bpy.props import IntProperty, FloatProperty, BoolProperty, IntVectorProperty, StringProperty, FloatVectorProperty, CollectionProperty
from bpy_extras import view3d_utils
import math
from math import *
@@ -163,13 +163,48 @@
if ob.custom_linkscale and xmove:
v = view3d_utils.location_3d_to_region_2d(context.area.regions[4], sd.region_3d, c + ce/ob.custom_old_scale.x*ob.custom_scale.x)
res = [round(v.x),round(v.y), ob.custom_location.z]
- ob.custom_location = res
-
- else:
+ ob.custom_location = res
+ else:
align_to_view(context)
ob.custom_old_scale = ob.custom_scale
+def update_activeviewname(self, context):
+ if self.custom_active:
+ context.object.custom_active_view = self.custom_active_view
+
+class custom_props(bpy.types.PropertyGroup):
+ custom_location = FloatVectorProperty(name="Location", description="Location of the plan",
+ default=(0,0,-1.0),
+ subtype = 'XYZ', size=3)
+
+ custom_rotation = IntProperty(name="Rotation", description="Rotate the plane",
+ min=-180, max=180, default=0)
+
+ custom_scale = FloatVectorProperty(name="Scales", description="Scale the planes",
+ subtype = 'XYZ', default=(1.0, 1.0),min = 0.1, size=2)
+
+ custom_linkscale = BoolProperty(name="linkscale", default=True)
+
+ # UV properties
+ custom_scaleuv = FloatVectorProperty(name="ScaleUV", description="Scale the texture's UV",
+ default=(1.0,1.0),min = 0.01, subtype = 'XYZ', size=2)
+ custom_offsetuv = FloatVectorProperty(name="OffsetUV", description="Decal the texture's UV",
+ default=(0.0,0.0), subtype = 'XYZ', size=2)
+ custom_linkscaleuv = BoolProperty(name="linkscaleUV", default=True)
+ custom_flipuvx = BoolProperty(name="flipuvx", default=False)
+ custom_flipuvy = BoolProperty(name="flipuvy", default=False)
+
+ # other properties
+ custom_active= BoolProperty(name="custom_active", default=False)
+ custom_expand = BoolProperty(name="expand", default=False)
+
+ custom_active_view = StringProperty(name = "custom_active_view",default = "View",update = update_activeviewname)
+
+ custom_image = StringProperty(name = "custom_image",default = "")
+
+ custom_index = IntProperty()
+
# Function to create custom properties
def createcustomprops(context):
Ob = bpy.types.Object
@@ -213,19 +248,132 @@
Ob.custom_c3d = BoolProperty(name="c3d", default=True)
Ob.custom_rot = BoolProperty(name="rot", default=True)
Ob.custom_rotc3d = BoolProperty(name="rotc3d", default=False)
- Ob.custom_scac3d = BoolProperty(name="scac3d", default=False)
+ Ob.custom_scac3d = BoolProperty(name="scac3d", default=False)
+ Ob.custom_expand = BoolProperty(name="expand", default=True)
+ Ob.custom_active_view = StringProperty(name = "custom_active_view",default = "View")
+
+ Ob.custom_props = CollectionProperty(type = custom_props)
# Function to remove custom properties
def removecustomprops():
list_prop = ['custom_location', 'custom_rotation', 'custom_old_rotation', 'custom_scale', 'custom_old_scale', 'custom_c3d',
'custom_rot', 'custom_rotc3d', 'custom_scaleuv', 'custom_flipuvx', 'custom_flipuvy', 'custom_linkscale',
- 'custom_linkscaleuv', 'custom_old_scaleuv', 'custom_offsetuv', 'custom_old_offsetuv', 'custom_scac3d', 'custom_sub']
+ 'custom_linkscaleuv', 'custom_old_scaleuv', 'custom_offsetuv', 'custom_old_offsetuv', 'custom_scac3d', 'custom_sub',
+ 'custom_expand', 'custom_active_view', 'custom_props']
for prop in list_prop:
try:
del bpy.context.object[prop]
except:
do = 'nothing'
+# Oprerator Class to create view
+class CreateView(Operator):
+ bl_idname = "object.create_view"
+ bl_label = "Create a new view"
+
+ def execute(self, context):
+ ob = context.object
+ new_props = ob.custom_props.add()
+
+ ob.custom_active_view = new_props.custom_active_view
+ new_props.custom_index = len(bpy.context.object.custom_props)-1
+ for item in ob.custom_props:
+ item.custom_active = False
+ new_props.custom_active = True
+ bpy.ops.object.copy_view(index = len(bpy.context.object.custom_props)-1)
+
+ return {'FINISHED'}
+
+# Oprerator Class to copy view
+class Copyiew(Operator):
+ bl_idname = "object.copy_view"
+ bl_label = "copy the view"
+
+ index = IntProperty(default = 0)
+
+ def execute(self, context):
+ ob = context.object
+ prop = ob.custom_props[self.index]
+ prop.custom_location = ob.custom_location
+ prop.custom_rotation = ob.custom_rotation
+ prop.custom_scale = ob.custom_scale
+ prop.custom_linkscale = ob.custom_linkscale
+ prop.custom_scaleuv = ob.custom_scaleuv
+ prop.custom_offsetuv = ob.custom_offsetuv
+ prop.custom_linkscaleuv = ob.custom_linkscaleuv
+ prop.custom_flipuvx = ob.custom_flipuvx
+ prop.custom_flipuvy = ob.custom_flipuvy
+ prop.custom_image = bpy.data.textures['Texture for BProjection'].image.name
+ #bpy.ops.object.active_view(index = self.index)
+
+ return {'FINISHED'}
+
+# Oprerator Class to copy view
+class Pasteview(Operator):
+ bl_idname = "object.paste_view"
+ bl_label = "paste the view"
+
+ index = IntProperty(default = 0)
+
+ def execute(self, context):
+ ob = context.object
+ prop = ob.custom_props[self.index]
+ ob.custom_linkscale = prop.custom_linkscale
+ ob.custom_scaleuv = prop.custom_scaleuv
+ ob.custom_offsetuv = prop.custom_offsetuv
+ ob.custom_linkscaleuv = prop.custom_linkscaleuv
+ ob.custom_rotation = prop.custom_rotation
+ ob.custom_scale = prop.custom_scale
+ ob.custom_location = prop.custom_location
+ if bpy.data.textures['Texture for BProjection'].image.name != prop.custom_image:
+ bpy.data.textures['Texture for BProjection'].image = bpy.data.images[prop.custom_image]
+ bpy.ops.object.applyimage()
+ if ob.custom_flipuvx != prop.custom_flipuvx:
+ ob.custom_flipuvx = prop.custom_flipuvx
+ if ob.custom_flipuvy != prop.custom_flipuvy:
+ ob.custom_flipuvy = prop.custom_flipuvy
+
+ return {'FINISHED'}
+
+# Oprerator Class to remove view
+class RemoveView(Operator):
+ bl_idname = "object.remove_view"
+ bl_label = "Rmeove the view"
+
+ index = IntProperty(default = 0)
+
+ def execute(self, context):
+ ob = context.object
+ if context.object.custom_props[self.index].custom_active:
+ if len(ob.custom_props) > 0:
+ bpy.ops.object.active_view(index = self.index-1)
+ if self.index == 0 and len(ob.custom_props) > 1:
+ bpy.ops.object.active_view(index = 1)
+
+ ob.custom_props.remove(self.index)
+ i=0
+ for item in context.object.custom_props:
+ item.custom_index = i
+ i+=1
+
+ return {'FINISHED'}
+
+# Oprerator Class to copy view
+class ActiveView(Operator):
+ bl_idname = "object.active_view"
+ bl_label = "Active the view"
+
+ index = IntProperty(default = 0)
+
+ def execute(self, context):
+ for item in context.object.custom_props:
+ item.custom_active = False
+ context.object.custom_props[self.index].custom_active = True
+ context.object.custom_active_view = context.object.custom_props[self.index].custom_active_view
+ bpy.ops.object.paste_view(index = self.index)
+
+ return {'FINISHED'}
+
# Draw Class to show the panel
class BProjection(Panel):
bl_space_type = 'VIEW_3D'
@@ -247,48 +395,73 @@
col = layout.column(align =True)
col.operator("object.removebprojectionplane", text="Remove BProjection plane")
+
box = layout.box()
- col = box.column(align =True)
- col.template_ID(tex, "image", open="image.open")
- row = box.row(align=True)
- row.operator('object.applyimage', text="Apply image", icon = 'FILE_TICK')
- row.prop(ob, "custom_c3d",text="", icon='CURSOR')
- row.prop(ob, "custom_rot",text="", icon='ROTATE')
- row = box.row(align =True)
- row.label(text="Location:")
- row = box.row(align =True)
- row.prop(ob,'custom_location', text='')
- row = box.row(align =True)
- row.prop(ob,'custom_rotation')
- row.prop(ob,'custom_rotc3d',text="",icon='MANIPUL')
- row = box.row(align =True)
- row.label(text="Scale:")
- row = box.row(align =True)
- row.prop(ob,'custom_scale',text='')
- if ob.custom_linkscale :
- row.prop(ob, "custom_linkscale",text="",icon='LINKED')
- else:
- row.prop(ob, "custom_linkscale",text="",icon='UNLINKED')
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-extensions-cvs
mailing list