[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [40920] trunk/blender: - bpy.path.abspath( ), added optional library argument since any paths from linked datablocks are relative to this , not the blend files path, this saves kludgy path code wherever libraries may be used.
Campbell Barton
ideasman42 at gmail.com
Tue Oct 11 06:09:12 CEST 2011
Revision: 40920
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=40920
Author: campbellbarton
Date: 2011-10-11 04:09:11 +0000 (Tue, 11 Oct 2011)
Log Message:
-----------
- bpy.path.abspath(), added optional library argument since any paths from linked datablocks are relative to this, not the blend files path, this saves kludgy path code wherever libraries may be used.
- Image "Edit Externally" operator can now edit relative library images.
also minor edits to navmesh.
Modified Paths:
--------------
trunk/blender/release/scripts/modules/bpy/path.py
trunk/blender/release/scripts/startup/bl_operators/image.py
trunk/blender/source/blender/blenkernel/intern/DerivedMesh.c
trunk/blender/source/blender/editors/mesh/mesh_navmesh.c
Modified: trunk/blender/release/scripts/modules/bpy/path.py
===================================================================
--- trunk/blender/release/scripts/modules/bpy/path.py 2011-10-10 22:06:07 UTC (rev 40919)
+++ trunk/blender/release/scripts/modules/bpy/path.py 2011-10-11 04:09:11 UTC (rev 40920)
@@ -40,7 +40,7 @@
import os as _os
-def abspath(path, start=None):
+def abspath(path, start=None, library=None):
"""
Returns the absolute path relative to the current blend file
using the "//" prefix.
@@ -48,8 +48,13 @@
:arg start: Relative to this path,
when not set the current filename is used.
:type start: string
+ :arg library: The library this path is from. This is only included for
+ convenience, when the library is not None its path replaces *start*.
+ :type library: :class:`bpy.types.Library`
"""
if path.startswith("//"):
+ if library:
+ start = abspath(_os.path.dirname(library.filepath))
return _os.path.join(_os.path.dirname(_bpy.data.filepath)
if start is None else start,
path[2:],
Modified: trunk/blender/release/scripts/startup/bl_operators/image.py
===================================================================
--- trunk/blender/release/scripts/startup/bl_operators/image.py 2011-10-10 22:06:07 UTC (rev 40919)
+++ trunk/blender/release/scripts/startup/bl_operators/image.py 2011-10-11 04:09:11 UTC (rev 40920)
@@ -69,8 +69,6 @@
self.report({'ERROR'}, "Image path not set")
return {'CANCELLED'}
- filepath = os.path.normpath(bpy.path.abspath(filepath))
-
if not os.path.exists(filepath):
self.report({'ERROR'},
"Image path %r not found, image may be packed or "
@@ -93,15 +91,16 @@
return {'FINISHED'}
def invoke(self, context, event):
+ import os
try:
- filepath = context.space_data.image.filepath
- except:
- import traceback
- traceback.print_exc()
- self.report({'ERROR'}, "Image not found on disk")
+ image = context.space_data.image
+ except AttributeError:
+ self.report({'ERROR'}, "Context incorrect, image not found")
return {'CANCELLED'}
- self.filepath = filepath
+ filepath = bpy.path.abspath(image.filepath, library=image.library)
+
+ self.filepath = os.path.normpath(filepath)
self.execute(context)
return {'FINISHED'}
Modified: trunk/blender/source/blender/blenkernel/intern/DerivedMesh.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/DerivedMesh.c 2011-10-10 22:06:07 UTC (rev 40919)
+++ trunk/blender/source/blender/blenkernel/intern/DerivedMesh.c 2011-10-11 04:09:11 UTC (rev 40920)
@@ -64,6 +64,7 @@
#ifdef WITH_GAMEENGINE
#include "BKE_navmesh_conversion.h"
+static DerivedMesh *navmesh_dm_createNavMeshForVisualization(DerivedMesh *dm);
#endif
#include "BLO_sys_types.h" // for intptr_t support
@@ -77,8 +78,6 @@
extern GLubyte stipple_quarttone[128]; /* glutil.c, bad level data */
-static DerivedMesh *navmesh_dm_createNavMeshForVisualization(DerivedMesh *dm);
-
///////////////////////////////////
///////////////////////////////////
Modified: trunk/blender/source/blender/editors/mesh/mesh_navmesh.c
===================================================================
--- trunk/blender/source/blender/editors/mesh/mesh_navmesh.c 2011-10-10 22:06:07 UTC (rev 40919)
+++ trunk/blender/source/blender/editors/mesh/mesh_navmesh.c 2011-10-11 04:09:11 UTC (rev 40920)
@@ -459,12 +459,14 @@
MEM_freeN(verts);
MEM_freeN(tris);
+
+ return OPERATOR_FINISHED;
}
else {
BKE_report(op->reports, RPT_ERROR, "No mesh objects found");
+
+ return OPERATOR_CANCELLED;
}
-
- return OPERATOR_FINISHED;
}
void MESH_OT_navmesh_make(wmOperatorType *ot)
More information about the Bf-blender-cvs
mailing list