Reputation: 1
There's my first operator, it do many things but you have to know, that it does makes vertex group "Heel".
class HEEL_OT_cut_heel(bpy.types.Operator):
"""Go to -Z pointview, then select scan object and press this button to create a heel."""
bl_label = "Cut heel"
bl_idname = "mesh.cut_heel_operator"
@classmethod
def poll(cls, context):
return context.active_object is not None
def execute(self, context):
...
group_heel = cut_and_clean(scan, curve)
group_heel.name = 'Heel'
...
return {'FINISHED'}
There's my second operator:
class HEEL_OT_elongate_heel(bpy.types.Operator):
"""If scan have hell vertex group, press this button to enlongate it"""
bl_label = 'Elongate heel'
bl_idname = 'mesh.elongate_heel_operator'
bl_options = {'REGISTER', 'UNDO'}
@classmethod
def poll(cls, context):
return context.active_object is not None
transition_value: bpy.props.FloatProperty(
default = 15,
soft_min = 10,
soft_max = 25
)
def get_transition_value(self):
return self.transition_value
def set_transition_value(self, x):
self.transition_value = x
def invoke(self, context, event):
self.set_transition_value(bpy.context.scene.heel_transition_value)
return self.execute(context)
def execute(self, context):
scan = bpy.context.active_object
if scan.mode != 'OBJECT':
bpy.ops.object.mode_set(mode = 'OBJECT')
if validation_scan(scan):
self.report({'ERROR'}, "Object is not configurated.")
return {'CANCELLED'}
group_heel = scan.vertex_groups.get("Heel")
if not group_heel:
self.report({'ERROR'}, "Object don't have 'Heel' vertex group.")
return {'CANCELLED'}
select_vertex_group(scan, group_heel)
bpy.ops.object.mode_set(mode = 'EDIT')
# Scale to cursor
bpy.context.scene.cursor.location[2] = get_min_z(scan)
bpy.context.scene.tool_settings.transform_pivot_point = 'CURSOR'
bpy.ops.object.mode_set(mode = 'EDIT')
bpy.ops.transform.resize(
value=(1, 1, 0),
orient_type='GLOBAL',
orient_matrix_type='GLOBAL',
constraint_axis=(True, True, True),
mirror=True,
use_proportional_edit=True,
proportional_edit_falloff='SHARP',
proportional_size = self.get_transition_value(),
use_proportional_connected=True
)
bpy.ops.object.mode_set(mode = 'OBJECT')
bpy.context.scene.heel_transition_value = self.get_transition_value()
return {'FINISHED'}
When I use first operator on active object and then without other action (move, scale, etc.) I use second operator, it do take those both actions as one. This is how I do understand this. When I try to undo it with Ctrl + Z shortcut, then I get back before vertex group "Heel" has been assigned. And when I try change transition_value in Redo Panel, second operator also didn't get vertex group "Heel", because it wasn't there.
I'm still learning Blender library, so if you see something ugly in my code, please, let me know.
Upvotes: 0
Views: 107