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.
This commit is contained in:
@@ -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)
|
||||
|
@@ -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'}
|
||||
|
@@ -94,11 +94,11 @@ static PyObject *make_app_info(void)
|
||||
SetStrItem(build_platform);
|
||||
SetStrItem(build_type);
|
||||
#else
|
||||
SetStrItem("Unknown");
|
||||
SetStrItem("Unknown");
|
||||
SetStrItem("Unknown");
|
||||
SetStrItem("Unknown");
|
||||
SetStrItem("Unknown");
|
||||
SetStrItem("Unknown");
|
||||
SetStrItem("Unknown");
|
||||
SetStrItem("Unknown");
|
||||
SetStrItem("Unknown");
|
||||
SetStrItem("Unknown");
|
||||
#endif
|
||||
|
||||
#undef SetIntItem
|
||||
|
Reference in New Issue
Block a user