Skip to content
Snippets Groups Projects
curve_assign_shapekey.py 38.3 KiB
Newer Older
  • Learn to ignore specific revisions
  •     alignList : EnumProperty(name="Vertex Alignment", items = \
            [("-None-", 'Manual Alignment', "Align curve segments based on starting vertex"), \
             ('vertCo', 'Vertex Coordinates', 'Align curve segments based on vertex coordinates')], \
            description = 'Start aligning the vertices of target and shape keys from',
            default = '-None-')
    
        alignVal1 : EnumProperty(name="Value 1",
            items = matchList, default = 'minX', description='First align criterion')
    
        alignVal2 : EnumProperty(name="Value 2",
            items = matchList, default = 'maxY', description='Second align criterion')
    
        alignVal3 : EnumProperty(name="Value 3",
            items = matchList, default = 'minZ', description='Third align criterion')
    
        matchParts : EnumProperty(name="Match Parts", items = \
            [("-None-", 'None', "Don't match parts"), \
            ('default', 'Default', 'Use part (spline) order as in curve'), \
            ('custom', 'Custom', 'Use one of the custom criteria for part matching')], \
            description='Match disconnected parts', default = 'default')
    
        matchCri1 : EnumProperty(name="Value 1",
            items = matchList, default = 'minX', description='First match criterion')
    
        matchCri2 : EnumProperty(name="Value 2",
            items = matchList, default = 'maxY', description='Second match criterion')
    
        matchCri3 : EnumProperty(name="Value 3",
            items = matchList, default = 'minZ', description='Third match criterion')
    
        markVertex : BoolProperty(name="Mark Starting Vertices", \
            description='Mark first vertices in all splines of selected curves', \
                default = False, update = markVertHandler)
    
    
    class AssignShapeKeysPanel(bpy.types.Panel):
    
        bl_label = "Assign Shape Keys"
        bl_idname = "CURVE_PT_assign_shape_keys"
        bl_space_type = 'VIEW_3D'
        bl_region_type = 'UI'
        bl_category = "Tool"
    
        @classmethod
        def poll(cls, context):
            return context.mode in {'OBJECT', 'EDIT_CURVE'}
    
        def draw(self, context):
    
            layout = self.layout
            col = layout.column()
            params = context.window_manager.AssignShapeKeyParams
    
            if(context.mode  == 'OBJECT'):
                row = col.row()
                row.prop(params, "removeOriginal")
    
                row = col.row()
                row.prop(params, "space")
    
                row = col.row()
                row.prop(params, "alignList")
    
                if(params.alignList == 'vertCo'):
                    row = col.row()
                    row.prop(params, "alignVal1")
                    row.prop(params, "alignVal2")
                    row.prop(params, "alignVal3")
    
                row = col.row()
                row.prop(params, "matchParts")
    
                if(params.matchParts == 'custom'):
                    row = col.row()
                    row.prop(params, "matchCri1")
                    row.prop(params, "matchCri2")
                    row.prop(params, "matchCri3")
    
                row = col.row()
                row.operator("object.assign_shape_keys")
            else:
                col.prop(params, "markVertex", \
                    toggle = True)
    
    
    # registering and menu integration
    def register():
        bpy.utils.register_class(AssignShapeKeysPanel)
        bpy.utils.register_class(AssignShapeKeysOp)
        bpy.utils.register_class(AssignShapeKeyParams)
        bpy.types.WindowManager.AssignShapeKeyParams = \
            bpy.props.PointerProperty(type=AssignShapeKeyParams)
        bpy.utils.register_class(ModalMarkSegStartOp)
    
    def unregister():
        bpy.utils.unregister_class(AssignShapeKeysOp)
        bpy.utils.unregister_class(AssignShapeKeysPanel)
        del bpy.types.WindowManager.AssignShapeKeyParams
        bpy.utils.unregister_class(AssignShapeKeyParams)
        bpy.utils.unregister_class(ModalMarkSegStartOp)
    
    if __name__ == "__main__":
        register()