From e5ab8ebcb52a2d17e494c71fa036aa114106b989 Mon Sep 17 00:00:00 2001 From: curmil Date: Thu, 21 May 2020 00:59:05 +0200 Subject: [PATCH 1/3] Made importing and exporting mh rigs work in Blender 2.8 --- io_mhrigging_mhskel/__init__.py | 28 ++++++++++++------------ io_mhrigging_mhskel/export_mh_rigging.py | 16 +++++++------- io_mhrigging_mhskel/import_mh_rigging.py | 8 +++---- io_mhrigging_mhskel/shared_mh_rigging.py | 4 +++- 4 files changed, 29 insertions(+), 27 deletions(-) diff --git a/io_mhrigging_mhskel/__init__.py b/io_mhrigging_mhskel/__init__.py index c7937f3..799cce1 100644 --- a/io_mhrigging_mhskel/__init__.py +++ b/io_mhrigging_mhskel/__init__.py @@ -37,28 +37,29 @@ """ bl_info = { - 'name': 'Export: MakeHuman Rigging (.mhskel)', - 'author': 'Manuel Bastioni', - 'version': (1,0,2), - "blender": (2,6,0), - 'location': "File > Export > MakeHuman Rigging (.mhskel) and File > Import > MakeHuman Rigging (.mhskel)", - 'description': 'Export skeleton, groups and weights as mhskel file', - 'warning': '', - 'wiki_url': '', - 'category': 'MakeHuman'} - -import bpy + "name": "Export: MakeHuman Rigging (.mhskel)", + "author": "Manuel Bastioni", + "version": (1,0,3), + "blender": (2, 80, 0), + "location": "File > Export > MakeHuman Rigging (.mhskel) and File > Import > MakeHuman Rigging (.mhskel)", + "description": "Export skeleton, groups and weights as mhskel file", + "warning": "", + "wiki_url": (""), + "tracker_url": "", + "support": "COMMUNITY", + "category": "Import-Export"} + +import bpy + from . import shared_mh_rigging from . import export_mh_rigging from . import import_mh_rigging - def register(): shared_mh_rigging.register() export_mh_rigging.register() import_mh_rigging.register() - def unregister(): shared_mh_rigging.unregister() export_mh_rigging.unregister() @@ -67,4 +68,3 @@ def unregister(): if __name__ == "__main__": register() - diff --git a/io_mhrigging_mhskel/export_mh_rigging.py b/io_mhrigging_mhskel/export_mh_rigging.py index 5928923..e187367 100644 --- a/io_mhrigging_mhskel/export_mh_rigging.py +++ b/io_mhrigging_mhskel/export_mh_rigging.py @@ -390,7 +390,7 @@ def writeRiggingFile(context, filepath): # This is very important, because the armature # must be active in order to turn in edit mode. - bpy.context.scene.objects.active = armature + bpy.context.view_layer.objects.active = armature bones, rot_planes = getBonesData(basemesh, armature) joints = getJointsData(basemesh, armature) @@ -428,7 +428,7 @@ def writeRiggingFile(context, filepath): outfile.close() #Restore the initial active object - bpy.context.scene.objects.active = basemesh + bpy.context.view_layer.objects.active = basemesh return {'FINISHED'} """ @@ -444,7 +444,7 @@ def writeRiggingFile(context, filepath): from bpy.types import Operator def menu_func_export(self, context): - self.layout.operator(ExportMHRigging.bl_idname, text="MakeHuman rigging (.mhskel)") + self.layout.operator(ExportMHRigging.bl_idname, text="Makehuman Skeleton (.mhskel)") class ExportMHRigging(Operator, ExportHelper): """This appears in the tooltip of the operator and in the generated docs""" @@ -454,21 +454,21 @@ class ExportMHRigging(Operator, ExportHelper): # ImportHelper mixin class uses this filename_ext = ".mhskel" - filter_glob = StringProperty( + filter_glob: StringProperty( default="*.mhskel", options={'HIDDEN'}, ) - def execute(self, context): - return writeRiggingFile(context, self.filepath) + def execute(self, context): + return writeRiggingFile(context, self.filepath) def register(): bpy.utils.register_class(ExportMHRigging) - bpy.types.INFO_MT_file_export.append(menu_func_export) + bpy.types.TOPBAR_MT_file_export.append(menu_func_export) def unregister(): bpy.utils.unregister_class(ExportMHRigging) - bpy.types.INFO_MT_file_export.remove(menu_func_export) + bpy.types.TOPBAR_MT_file_export.remove(menu_func_export) if __name__ == "__main__": diff --git a/io_mhrigging_mhskel/import_mh_rigging.py b/io_mhrigging_mhskel/import_mh_rigging.py index 1ef6521..b7f61c7 100644 --- a/io_mhrigging_mhskel/import_mh_rigging.py +++ b/io_mhrigging_mhskel/import_mh_rigging.py @@ -27,7 +27,7 @@ def createArmatureFromJsonFile(filePath): weightsFile.close() for group, weights in weights.items(): - newGroup = basemesh.vertex_groups.new(group) + newGroup = basemesh.vertex_groups.new(name=group) for weightData in weights: newGroup.add([weightData[0]], weightData[1], 'ADD') @@ -130,7 +130,7 @@ class ImportMHRigging(Operator, ImportHelper): # ImportHelper mixin class uses this filename_ext = ".mhskel" - filter_glob = StringProperty( + filter_glob: StringProperty( default="*.mhskel", options={'HIDDEN'}, ) @@ -141,11 +141,11 @@ def execute(self, context): def register(): bpy.utils.register_class(ImportMHRigging) - bpy.types.INFO_MT_file_import.append(menu_func_import) + bpy.types.TOPBAR_MT_file_import.append(menu_func_import) def unregister(): bpy.utils.unregister_class(ImportMHRigging) - bpy.types.INFO_MT_file_import.remove(menu_func_import) + bpy.types.TOPBAR_MT_file_import.remove(menu_func_import) if __name__ == "__main__": diff --git a/io_mhrigging_mhskel/shared_mh_rigging.py b/io_mhrigging_mhskel/shared_mh_rigging.py index 3b84ec5..76efb30 100644 --- a/io_mhrigging_mhskel/shared_mh_rigging.py +++ b/io_mhrigging_mhskel/shared_mh_rigging.py @@ -179,8 +179,10 @@ "upperleg02.R____head": [4260 ,4308, 4407, 6394], "upperleg01.R____tail": [4260, 4308, 4407, 6394], "upperarm02.R____head": [1404, 1406, 1419, 1429, 1440, 1442, 1628, 1638, 1639, 1640, 1648, 1649, 1652, 1662, 3759, 3760], + "upperarm01.R____tail": [1404, 1406, 1419, 1429, 1440, 1442, 1628, 1638, 1639, 1640, 1648, 1649, 1652, 1662, 3759, 3760], "shoulder02.R____tail": [1404, 1406, 1419, 1429, 1440, 1442, 1628, 1638, 1639, 1640, 1648, 1649, 1652, 1662, 3759, 3760], "upperarm02.L____head": [8092, 8094, 8107, 8117, 8128, 8130, 8300, 8310, 8311, 8312, 8320, 8321, 8324, 8334, 10426, 10427], + "upperarm01.L____tail": [8092, 8094, 8107, 8117, 8128, 8130, 8300, 8310, 8311, 8312, 8320, 8321, 8324, 8334, 10426, 10427], "shoulder02.L____tail": [8092, 8094, 8107, 8117, 8128, 8130, 8300, 8310, 8311, 8312, 8320, 8321, 8324, 8334, 10426, 10427], "tongue07.L____head": [14558, 14559, 14560, 14561, 14562, 14563, 14564, 14565, 14550, 14551, 14552, 14553, 14554, 14555, 14556, 14557], "tongue07.R____head": [14558, 14559, 14560, 14561, 14562, 14563, 14564, 14565, 14550, 14551, 14552, 14553, 14554, 14555, 14556, 14557], @@ -262,7 +264,7 @@ def getObject(): if len(bpy.context.selected_objects) > 0: #Get latest selected obj and make it the active one - bpy.context.scene.objects.active = bpy.context.selected_objects[0] + bpy.context.view_layer.objects.active = bpy.context.selected_objects[0] activeObject = bpy.context.object return activeObject From e8345af41f5eb38162e0da03282c80ed969cf1ed Mon Sep 17 00:00:00 2001 From: curmil <913100+curmil@users.noreply.github.com> Date: Thu, 21 May 2020 01:01:33 +0200 Subject: [PATCH 2/3] Update export_mh_rigging.py --- io_mhrigging_mhskel/export_mh_rigging.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/io_mhrigging_mhskel/export_mh_rigging.py b/io_mhrigging_mhskel/export_mh_rigging.py index e187367..32366b6 100644 --- a/io_mhrigging_mhskel/export_mh_rigging.py +++ b/io_mhrigging_mhskel/export_mh_rigging.py @@ -444,7 +444,7 @@ def writeRiggingFile(context, filepath): from bpy.types import Operator def menu_func_export(self, context): - self.layout.operator(ExportMHRigging.bl_idname, text="Makehuman Skeleton (.mhskel)") + self.layout.operator(ExportMHRigging.bl_idname, text="Makehuman rigging (.mhskel)") class ExportMHRigging(Operator, ExportHelper): """This appears in the tooltip of the operator and in the generated docs""" From 1e1a56479bc1deac613802e891abf440cbeb342e Mon Sep 17 00:00:00 2001 From: curmil <913100+curmil@users.noreply.github.com> Date: Thu, 21 May 2020 01:01:53 +0200 Subject: [PATCH 3/3] Update export_mh_rigging.py --- io_mhrigging_mhskel/export_mh_rigging.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/io_mhrigging_mhskel/export_mh_rigging.py b/io_mhrigging_mhskel/export_mh_rigging.py index 32366b6..c21159c 100644 --- a/io_mhrigging_mhskel/export_mh_rigging.py +++ b/io_mhrigging_mhskel/export_mh_rigging.py @@ -444,7 +444,7 @@ def writeRiggingFile(context, filepath): from bpy.types import Operator def menu_func_export(self, context): - self.layout.operator(ExportMHRigging.bl_idname, text="Makehuman rigging (.mhskel)") + self.layout.operator(ExportMHRigging.bl_idname, text="MakeHuman rigging (.mhskel)") class ExportMHRigging(Operator, ExportHelper): """This appears in the tooltip of the operator and in the generated docs"""