Skip to content

Commit

Permalink
Improve blender 3.3 capabilities
Browse files Browse the repository at this point in the history
- Added undo support for "Fit to Armature" and "Fit to Mesh" buttons
- update Modifier signature for new BLender API
  https://projects.blender.org/blender/blender/commit/01c8aa12a177
- Added simple hashing function intended for Vectorns
- Extended stripName to include clean path naming for exporting groups
  ins dmesh format
  • Loading branch information
SmittyWerbenJJ committed Jul 5, 2023
1 parent 9712de5 commit 4094bea
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions HaydeeUtils.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@ def boneRenameHaydee(bone_name):


def stripName(name):
return name.replace(" ", "_").replace("*", "_").replace("-", "_")
""" Remove invalid characters from a name"""
out=name.replace(" ", "_").replace("*", "_").replace("-", "_")
return bpy.path.clean_name(out)


def decodeText(text):
Expand All @@ -47,6 +49,11 @@ def d(number):
return "0"
return r

def hashedN(numbers):
if type(numbers) is not tuple:
return hash(tuple(numbers))

return hash(numbers)
# --------------------------------------------------------------------------------
# Finds a suitable armature in the current selection or scene
# --------------------------------------------------------------------------------
Expand Down Expand Up @@ -131,7 +138,7 @@ def apply_pose(selected, active):
index = obj.modifiers.find(modif.name)
bpy.ops.object.modifier_copy(modifier=modif.name)
new_modif_name = obj.modifiers[index + 1].name
bpy.ops.object.modifier_apply(apply_as='DATA', modifier=new_modif_name)
bpy.ops.object.modifier_apply(modifier=new_modif_name)
modif.object = active
bpy.context.view_layer.objects.active = active

Expand Down Expand Up @@ -173,7 +180,7 @@ class HaydeeToolFitArmature_Op(bpy.types.Operator):
bl_idname = 'haydee_tools.fit_to_armature'
bl_label = 'Cycles'
bl_description = 'Select the mesh armature then the haydee Skel. Raplces the Armature with the skel. Uses the Skel pose'
bl_options = {'PRESET'}
bl_options = {'PRESET',"UNDO"}

def execute(self, context):
fit_to_armature()
Expand All @@ -184,7 +191,7 @@ class HaydeeToolFitMesh_Op(bpy.types.Operator):
bl_idname = 'haydee_tools.fit_to_mesh'
bl_label = 'Cycles'
bl_description = 'Select the mesh armature then the haydee Skel. Raplces the Armature with the skel. Uses the Armature pose'
bl_options = {'PRESET'}
bl_options = {'PRESET',"UNDO"}

def execute(self, context):
fit_to_mesh()
Expand Down

0 comments on commit 4094bea

Please sign in to comment.