From b9b534687ab8c0cefca3a44d3457b035eab51467 Mon Sep 17 00:00:00 2001
From: Thomas Larsson <thomas_larsson_01@hotmail.com>
Date: Tue, 21 May 2013 07:20:13 +0000
Subject: [PATCH] MHX importer rigify mode now fails gracefully when rigify is
 not enabled.

---
 io_import_scene_mhx.py | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/io_import_scene_mhx.py b/io_import_scene_mhx.py
index 94a191503..d0eb5a585 100644
--- a/io_import_scene_mhx.py
+++ b/io_import_scene_mhx.py
@@ -2580,7 +2580,10 @@ def rigifyMhx(context):
     bpy.ops.object.mode_set(mode='OBJECT')   
     
     # Create metarig    
-    bpy.ops.object.armature_human_metarig_add()
+    try:
+        bpy.ops.object.armature_human_metarig_add()
+    except AttributeError:
+        raise MyError("The Rigify add-on is not enabled. It is found under rigging.")
     bpy.ops.object.location_clear()
     bpy.ops.object.rotation_clear()
     bpy.ops.object.scale_clear()
@@ -2718,10 +2721,12 @@ def rigifyMhx(context):
     #Clean up    
     gen.show_x_ray = True
     gen.data.draw_type = 'STICK'
+    gen.MhxRigify = False    
     name = rig.name
     scn.objects.unlink(rig)
     del rig
     gen.name = name
+    bpy.ops.object.mode_set(mode='POSE')
     print("MHX rig %s successfully rigified" % name)
     
     
-- 
GitLab