Property problem

Compiling, libraries, modules, coding guidelines and porting

Moderators: jesterKing, stiv

Post Reply
Alagarsamy
Posts: 0
Joined: Fri Aug 30, 2013 11:57 am
Location: India

Property problem

Post by Alagarsamy »

The below coding I'm using at python. All properties and offset value are not working. How do i work the properties using python?


The python code is


class Extrude_individual_face(bpy.types.Operator):
bl_idname = "extrudeindividual_face.selected"
bl_label = "Extrude Individual Faces "
bl_options = {'REGISTER', 'UNDO'}

offset = FloatProperty(name = "", description = "", default = 0.0, min = -10.0, max = 10.0,precision = 2,subtype = 'FACTOR')
propo_edit = EnumProperty(items = (('one', 'DISABLED', 'Disable','PROP_OFF', 1),('two', 'ENABLED','Enable','PROP_ON',2),('three', 'PROJECTED', 'Projected (2D)','PROP_ON',3),('four', 'CONNECTED', 'Connected','PROP_CON',4)),default = 'one', name = "")
propo_edit_fall = EnumProperty(items = (('one', 'SMOOTH', 'Smooth','SMOOTHCURVE', 1),('two', 'SPHERE','Sphere','SPHERECURVE', 2),('three', 'ROOT', 'Root','ROOTCURVE', 3),('four', 'SHARP', 'Sharp','SHARPCURVE', 4),('five', 'LINEAR', 'Linear','LINCURVE', 5),('six', 'CONSTANT', 'Constant','NOCURVE',6),('seven', 'RANDOM', 'Random','RNDCURVE', 7)),default = 'one',name = "")

propo_size = FloatProperty(name = "", description = "", default = 1, min = 0.001, max = 100.000)
release = BoolProperty(name="release on confirm", description="release on confirm", default=False)

def draw(self,context):

layout = self.layout
layout.label("Shirnk/Fatten")
layout.label("Offset")
layout.prop(self, 'offset', slider = True)
layout.label("Proportional Edit")
layout.prop(self,'propo_edit')
layout.label("Proportional Edit Falloff")
layout.prop(self,'propo_edit_fall')
layout.label("Proportional size")
layout.prop(self,'propo_size')
layout.prop(self, 'release')

def extrude (self,con,fall,release):

bpy.ops.mesh.extrude_faces_move(MESH_OT_extrude_faces_indiv={"mirror":False}, TRANSFORM_OT_shrink_fatten={"value":self.offset, "mirror":False, "proportional":con, "proportional_edit_falloff":fall, "proportional_size":1, "snap":False, "snap_target":'CLOSEST', "snap_point":(0, 0, 0), "snap_align":False, "snap_normal":(0, 0, 0), "release_confirm":release})

def execute(self, context):

if self.propo_edit == 'one':
con = 'DISABLED'
elif self.propo_edit == 'two':
con = 'ENABLED'
elif self.propo_edit == 'three':
con = 'PROJECTED'
elif self.propo_edit == 'four':
con = 'CONNECTED'

if self.propo_edit_fall == 'one':
fall = 'SMOOTH'
elif self.propo_edit_fall == 'two':
fall = 'SPHERE'
elif self.propo_edit_fall == 'three':
fall = 'ROOT'
elif self.propo_edit_fall == 'four':
fall = 'SHARP'
elif self.propo_edit_fall == 'five':
fall = 'LINEAR'
elif self.propo_edit_fall == 'six':
fall = 'CONSTANT'
elif self.propo_edit_fall == 'seven':
fall = 'RANDOM'

if self.release == True:
release = True
else:
release = False
self.extrude(con,fall,release)

return {'FINISHED'}

def modal(self, context, event):
global ti, delta1, deltay1, et, x, y
delta = 0
mesh = context.object.data
selected_mode = context.tool_settings.mesh_select_mode
totface = mesh.total_face_sel
totedge = mesh.total_edge_sel
self.offset += 0.01
#self.value = bpy.context.scene.offset
if context.active_object.mode == 'EDIT':
if ti == 0:
if selected_mode[2] and totface>=1:
bpy.ops.mesh.extrude_faces_move()
ti = 1
bm=bmesh.from_edit_mesh(mesh)

if event.type == 'MOUSEMOVE':
if totface >= 1:
for v in bm.faces:
v.normal_update()
if v.select:
et = "face"

bpy.ops.transform.shrink_fatten(value= self.offset, mirror=False, proportional = 'DISABLED', proportional_edit_falloff='SMOOTH', proportional_size=1.0, snap=False, snap_target='CLOSEST', snap_point=(0.0, 0.0, 0.0), snap_align=False, snap_normal=(0.0, 0.0, 0.0), release_confirm=False)

x = x + delta * 0.02
self.offset = x


elif event.type == 'LEFTMOUSE':
ti = 0
delta1=0
deltay1=0
x = 0
y = 0
z = 0
return {'FINISHED'}
elif event.type in {'RIGHTMOUSE', 'ESC'}:
if totface >= 1:
for v in bm.faces:
if v.select:
bpy.ops.transform.shrink_fatten(value=-x/totface)

ti = 0
delta1=0
deltay1=0
x = 0
y = 0
z = 0
return {'FINISHED'}
else:
return {'CANCELLED'}
return {'RUNNING_MODAL'}

def invoke(self, context, event):
if context.object:
self.first_mouse_x = event.mouse_x
self.first_mouse_y = event.mouse_y
context.window_manager.modal_handler_add(self)
return {'RUNNING_MODAL'}
else:
self.report({'WARNING'}, "No active object, could not finish")
return {'CANCELLED'}
return {'FINISHED'}

Post Reply