diff options
author | Campbell Barton <ideasman42@gmail.com> | 2010-10-13 04:08:24 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2010-10-13 04:08:24 +0400 |
commit | 118e0426f109fb41fa5d9c982ffdce2661b1157a (patch) | |
tree | d9cb5e896072d4549ebb40ea3cd70c3171cb8093 /release | |
parent | 4a385adbf339f585cc1802a1e5d277ff99438146 (diff) |
patch [#24221] Creating graph from armature doesn't work with unsaved .blend files (with fix).
from Sergej Reich (sergof)
Made some corrections to the patch as well as using bpy.app.tempdir with tempfile python module.
Diffstat (limited to 'release')
-rw-r--r-- | release/scripts/modules/rigify/__init__.py | 6 | ||||
-rw-r--r-- | release/scripts/ui/properties_data_armature_rigify.py | 13 |
2 files changed, 16 insertions, 3 deletions
diff --git a/release/scripts/modules/rigify/__init__.py b/release/scripts/modules/rigify/__init__.py index 98d9bb235a2..c4f18d51519 100644 --- a/release/scripts/modules/rigify/__init__.py +++ b/release/scripts/modules/rigify/__init__.py @@ -534,7 +534,11 @@ def generate_test_all(context, GRAPH=False): new_objects = rigify.generate_test(context) if GRAPH: - base_name = os.path.splitext(bpy.data.filepath)[0] + if(bpy.data.filepath): + base_name = os.path.splitext(bpy.data.filepath)[0] + else: + import tempfile + base_name = tempfile.mktemp(prefix=bpy.app.tempdir) for obj, obj_new in new_objects: for obj in (obj, obj_new): fn = base_name + "-" + bpy.path.clean_name(obj.name) diff --git a/release/scripts/ui/properties_data_armature_rigify.py b/release/scripts/ui/properties_data_armature_rigify.py index f7961821277..6453ea9e038 100644 --- a/release/scripts/ui/properties_data_armature_rigify.py +++ b/release/scripts/ui/properties_data_armature_rigify.py @@ -211,14 +211,23 @@ class Graph(bpy.types.Operator): import bpy reload(graphviz_export) obj = bpy.context.object - path = os.path.splitext(bpy.data.filepath)[0] + "-" + bpy.path.clean_name(obj.name) + if(bpy.data.filepath): + path = os.path.splitext(bpy.data.filepath)[0] + "-" + bpy.path.clean_name(obj.name) + else: + import tempfile + path = tempfile.mktemp(prefix=bpy.app.tempdir) + "-" + bpy.path.clean_name(obj.name) path_dot = path + ".dot" path_png = path + ".png" saved = graphviz_export.graph_armature(bpy.context.object, path_dot, CONSTRAINTS=False, DRIVERS=False) if saved: # if we seriously want this working everywhere we'll need some new approach - os.system("dot -Tpng %s > %s; gnome-open %s &" % (path_dot, path_png, path_png)) + os.system("dot -Tpng %r > %r" % (path_dot, path_png)) + if not os.path.exists(path_png) or os.stat(path_png)[6] == 0: + self.report('ERROR', "Graphvis could not create %r check graphviz is installed" % path_png) + return {'CANCELLED'} + + bpy.ops.image.external_edit(filepath=path_png) #os.system("python /b/xdot.py '%s' &" % path_dot) return {'FINISHED'} |