Add Easy_Weight
to Addons
#47
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -2,7 +2,7 @@ import bpy
|
|||||||
from bpy.props import *
|
from bpy.props import *
|
||||||
from bpy.app.handlers import persistent
|
from bpy.app.handlers import persistent
|
||||||
|
|
||||||
class ChangeWPBrush(bpy.types.Operator):
|
class EASYWEIGHT_OT_change_brush(bpy.types.Operator):
|
||||||
"""Change the weight paint brush to a specific brush."""
|
"""Change the weight paint brush to a specific brush."""
|
||||||
bl_idname = "brush.set_specific"
|
bl_idname = "brush.set_specific"
|
||||||
bl_label = "Set WP Brush"
|
bl_label = "Set WP Brush"
|
||||||
@ -51,7 +51,7 @@ def register_brush_switch_hotkeys(dummy):
|
|||||||
# Without this, the hotkeys' properties get reset whenever the addon is disabled, which results in having to set the Add, Subtract, Blur brushes on the hotkeys manually every time.
|
# Without this, the hotkeys' properties get reset whenever the addon is disabled, which results in having to set the Add, Subtract, Blur brushes on the hotkeys manually every time.
|
||||||
# However, with this, the hotkey cannot be changed, since this will forcibly re-create the original anyways.
|
# However, with this, the hotkey cannot be changed, since this will forcibly re-create the original anyways.
|
||||||
|
|
||||||
active_keyconfig = bpy.data.window_managers[0].keyconfigs.active
|
active_keyconfig = bpy.context.window_manager.keyconfigs.active
|
||||||
if not active_keyconfig: return # Avoid error when running without UI.
|
if not active_keyconfig: return # Avoid error when running without UI.
|
||||||
wp_hotkeys = active_keyconfig.keymaps['Weight Paint'].keymap_items
|
wp_hotkeys = active_keyconfig.keymaps['Weight Paint'].keymap_items
|
||||||
|
|
||||||
@ -69,10 +69,11 @@ def register_brush_switch_hotkeys(dummy):
|
|||||||
|
|
||||||
def register():
|
def register():
|
||||||
from bpy.utils import register_class
|
from bpy.utils import register_class
|
||||||
register_class(ChangeWPBrush)
|
register_class(EASYWEIGHT_OT_change_brush)
|
||||||
|
register_brush_switch_hotkeys(None)
|
||||||
bpy.app.handlers.load_post.append(register_brush_switch_hotkeys)
|
bpy.app.handlers.load_post.append(register_brush_switch_hotkeys)
|
||||||
|
|
||||||
def unregister():
|
def unregister():
|
||||||
from bpy.utils import unregister_class
|
from bpy.utils import unregister_class
|
||||||
unregister_class(ChangeWPBrush)
|
unregister_class(EASYWEIGHT_OT_change_brush)
|
||||||
bpy.app.handlers.load_post.remove(register_brush_switch_hotkeys)
|
bpy.app.handlers.load_post.remove(register_brush_switch_hotkeys)
|
@ -26,7 +26,7 @@ def flip_driver_targets(obj):
|
|||||||
print("target: " + t.bone_target)
|
print("target: " + t.bone_target)
|
||||||
t.bone_target = utils.flip_name(t.bone_target)
|
t.bone_target = utils.flip_name(t.bone_target)
|
||||||
|
|
||||||
class ForceApplyMirror(bpy.types.Operator):
|
class EASYWEIGHT_OT_force_apply_mirror(bpy.types.Operator):
|
||||||
""" Force apply mirror modifier by duplicating the object, flipping it on the X axis, merging into the original """
|
""" Force apply mirror modifier by duplicating the object, flipping it on the X axis, merging into the original """
|
||||||
bl_idname = "object.force_apply_mirror_modifier"
|
bl_idname = "object.force_apply_mirror_modifier"
|
||||||
bl_label = "Force Apply Mirror Modifier"
|
bl_label = "Force Apply Mirror Modifier"
|
||||||
@ -227,8 +227,8 @@ class ForceApplyMirror(bpy.types.Operator):
|
|||||||
|
|
||||||
def register():
|
def register():
|
||||||
from bpy.utils import register_class
|
from bpy.utils import register_class
|
||||||
register_class(ForceApplyMirror)
|
register_class(EASYWEIGHT_OT_force_apply_mirror)
|
||||||
|
|
||||||
def unregister():
|
def unregister():
|
||||||
from bpy.utils import unregister_class
|
from bpy.utils import unregister_class
|
||||||
unregister_class(ForceApplyMirror)
|
unregister_class(EASYWEIGHT_OT_force_apply_mirror)
|
@ -159,7 +159,7 @@ w3_bone_dict_str = """{
|
|||||||
'Hand_Def.R' : ['r_thumb_roll', 'r_pinky0', 'r_index_knuckleRoll', 'r_middle_knuckleRoll', 'r_ring_knuckleRoll'],
|
'Hand_Def.R' : ['r_thumb_roll', 'r_pinky0', 'r_index_knuckleRoll', 'r_middle_knuckleRoll', 'r_ring_knuckleRoll'],
|
||||||
}"""
|
}"""
|
||||||
|
|
||||||
class SmartWeightTransferOperator(bpy.types.Operator):
|
class EASYWEIGHT_OT_smart_weight_transfer(bpy.types.Operator):
|
||||||
""" Transfer weights from active to selected objects based on weighted vert distances """
|
""" Transfer weights from active to selected objects based on weighted vert distances """
|
||||||
bl_idname = "object.smart_weight_transfer"
|
bl_idname = "object.smart_weight_transfer"
|
||||||
bl_label = "Smart Transfer Weights"
|
bl_label = "Smart Transfer Weights"
|
||||||
@ -203,7 +203,7 @@ class SmartWeightTransferOperator(bpy.types.Operator):
|
|||||||
return (context.object is not None)# and (context.object.mode=='WEIGHT_PAINT')
|
return (context.object is not None)# and (context.object.mode=='WEIGHT_PAINT')
|
||||||
|
|
||||||
def draw_smart_weight_transfer(self, context):
|
def draw_smart_weight_transfer(self, context):
|
||||||
operator = self.layout.operator(SmartWeightTransferOperator.bl_idname, text=SmartWeightTransferOperator.bl_label)
|
operator = self.layout.operator(EASYWEIGHT_OT_smart_weight_transfer.bl_idname, text=EASYWEIGHT_OT_smart_weight_transfer.bl_label)
|
||||||
|
|
||||||
def execute(self, context):
|
def execute(self, context):
|
||||||
assert len(context.selected_objects) > 1, "At least two objects must be selected. Select the source object last, and enter weight paint mode."
|
assert len(context.selected_objects) > 1, "At least two objects must be selected. Select the source object last, and enter weight paint mode."
|
||||||
@ -253,10 +253,10 @@ class SmartWeightTransferOperator(bpy.types.Operator):
|
|||||||
|
|
||||||
def register():
|
def register():
|
||||||
from bpy.utils import register_class
|
from bpy.utils import register_class
|
||||||
register_class(SmartWeightTransferOperator)
|
register_class(EASYWEIGHT_OT_smart_weight_transfer)
|
||||||
bpy.types.VIEW3D_MT_paint_weight.append(SmartWeightTransferOperator.draw_smart_weight_transfer)
|
bpy.types.VIEW3D_MT_paint_weight.append(EASYWEIGHT_OT_smart_weight_transfer.draw_smart_weight_transfer)
|
||||||
|
|
||||||
def unregister():
|
def unregister():
|
||||||
from bpy.utils import unregister_class
|
from bpy.utils import unregister_class
|
||||||
unregister_class(SmartWeightTransferOperator)
|
unregister_class(EASYWEIGHT_OT_smart_weight_transfer)
|
||||||
bpy.types.VIEW3D_MT_paint_weight.remove(SmartWeightTransferOperator.draw_smart_weight_transfer)
|
bpy.types.VIEW3D_MT_paint_weight.remove(EASYWEIGHT_OT_smart_weight_transfer.draw_smart_weight_transfer)
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import bpy
|
import bpy
|
||||||
|
|
||||||
# This operator is to make entering weight paint mode less of a pain in the ass.
|
# This operator is to make entering weight paint mode less of a pain.
|
||||||
# You just need to select a mesh, run the operator, and you should be ready to weight paint.
|
# You just need to select a mesh, run the operator, and you should be ready to weight paint.
|
||||||
|
|
||||||
# It registers an operator called "Toggle Weight Paint Mode" that does the following:
|
# It registers an operator called "Toggle Weight Paint Mode" that does the following:
|
||||||
@ -16,7 +16,7 @@ import bpy
|
|||||||
|
|
||||||
coll_name = "temp_weight_paint_armature"
|
coll_name = "temp_weight_paint_armature"
|
||||||
|
|
||||||
class ToggleWeightPaint(bpy.types.Operator):
|
class EASYWEIGHT_OT_toggle_weight_paint(bpy.types.Operator):
|
||||||
"""Toggle weight paint mode properly with a single operator. """
|
"""Toggle weight paint mode properly with a single operator. """
|
||||||
bl_idname = "object.weight_paint_toggle"
|
bl_idname = "object.weight_paint_toggle"
|
||||||
bl_label = "Toggle Weight Paint Mode"
|
bl_label = "Toggle Weight Paint Mode"
|
||||||
@ -28,6 +28,9 @@ class ToggleWeightPaint(bpy.types.Operator):
|
|||||||
def poll(cls, context):
|
def poll(cls, context):
|
||||||
return context.object and context.object.type=='MESH'
|
return context.object and context.object.type=='MESH'
|
||||||
|
|
||||||
|
def draw(self, context):
|
||||||
|
self.layout.operator(EASYWEIGHT_OT_toggle_weight_paint.bl_idname)
|
||||||
|
|
||||||
def execute(self, context):
|
def execute(self, context):
|
||||||
obj = context.object
|
obj = context.object
|
||||||
|
|
||||||
@ -130,8 +133,12 @@ class ToggleWeightPaint(bpy.types.Operator):
|
|||||||
|
|
||||||
def register():
|
def register():
|
||||||
from bpy.utils import register_class
|
from bpy.utils import register_class
|
||||||
register_class(ToggleWeightPaint)
|
register_class(EASYWEIGHT_OT_toggle_weight_paint)
|
||||||
|
bpy.types.VIEW3D_MT_paint_weight.append(EASYWEIGHT_OT_toggle_weight_paint.draw)
|
||||||
|
bpy.types.VIEW3D_MT_object.append(EASYWEIGHT_OT_toggle_weight_paint.draw)
|
||||||
|
|
||||||
def unregister():
|
def unregister():
|
||||||
from bpy.utils import unregister_class
|
from bpy.utils import unregister_class
|
||||||
unregister_class(ToggleWeightPaint)
|
unregister_class(EASYWEIGHT_OT_toggle_weight_paint)
|
||||||
|
bpy.types.VIEW3D_MT_paint_weight.remove(EASYWEIGHT_OT_toggle_weight_paint.draw)
|
||||||
|
bpy.types.VIEW3D_MT_object.remove(EASYWEIGHT_OT_toggle_weight_paint.draw)
|
@ -2,7 +2,7 @@ import bpy
|
|||||||
from bpy.props import *
|
from bpy.props import *
|
||||||
from bpy.app.handlers import persistent
|
from bpy.app.handlers import persistent
|
||||||
|
|
||||||
class WPContextMenu(bpy.types.Operator):
|
class EASYWEIGHT_OT_wp_context_menu(bpy.types.Operator):
|
||||||
""" Custom Weight Paint context menu """
|
""" Custom Weight Paint context menu """
|
||||||
bl_idname = "object.custom_weight_paint_context_menu"
|
bl_idname = "object.custom_weight_paint_context_menu"
|
||||||
bl_label = "Custom Weight Paint Context Menu"
|
bl_label = "Custom Weight Paint Context Menu"
|
||||||
@ -120,10 +120,11 @@ def start_cleaner(scene, depsgraph):
|
|||||||
|
|
||||||
def register():
|
def register():
|
||||||
from bpy.utils import register_class
|
from bpy.utils import register_class
|
||||||
register_class(WPContextMenu)
|
register_class(EASYWEIGHT_OT_wp_context_menu)
|
||||||
|
start_cleaner(None, None)
|
||||||
bpy.app.handlers.load_post.append(start_cleaner)
|
bpy.app.handlers.load_post.append(start_cleaner)
|
||||||
|
|
||||||
def unregister():
|
def unregister():
|
||||||
from bpy.utils import unregister_class
|
from bpy.utils import unregister_class
|
||||||
unregister_class(WPContextMenu)
|
unregister_class(EASYWEIGHT_OT_wp_context_menu)
|
||||||
bpy.app.handlers.load_post.remove(start_cleaner)
|
bpy.app.handlers.load_post.remove(start_cleaner)
|
Loading…
Reference in New Issue
Block a user