[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [23507] trunk/blender: Added Image. get_abs_filename() and updated scripts to use it.
Arystanbek Dyussenov
arystan.d at gmail.com
Sun Sep 27 11:19:32 CEST 2009
Revision: 23507
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=23507
Author: kazanbas
Date: 2009-09-27 11:19:29 +0200 (Sun, 27 Sep 2009)
Log Message:
-----------
Added Image.get_abs_filename() and updated scripts to use it. This removes the necessity of bpy.sys.expandpath().
Added missing Object.dupli_list.
Modified Paths:
--------------
trunk/blender/release/io/export_fbx.py
trunk/blender/release/io/export_obj.py
trunk/blender/release/io/export_x3d.py
trunk/blender/release/io/import_3ds.py
trunk/blender/source/blender/makesrna/intern/rna_image_api.c
trunk/blender/source/blender/makesrna/intern/rna_object.c
Modified: trunk/blender/release/io/export_fbx.py
===================================================================
--- trunk/blender/release/io/export_fbx.py 2009-09-27 08:54:58 UTC (rev 23506)
+++ trunk/blender/release/io/export_fbx.py 2009-09-27 09:19:29 UTC (rev 23507)
@@ -94,6 +94,7 @@
file.close()
+# XXX not used anymore, images are copied one at a time
def copy_images(dest_dir, textures):
if not dest_dir.endswith(os.sep):
dest_dir += os.sep
@@ -1285,10 +1286,9 @@
base = os.path.basename(rel)
if EXP_IMAGE_COPY:
- src = bpy.sys.expandpath(image.filename)
absp = image.get_export_path(basepath, False)
if not os.path.exists(absp):
- shutil.copy(src, absp)
+ shutil.copy(image.get_abs_filename(), absp)
return (rel, base)
Modified: trunk/blender/release/io/export_obj.py
===================================================================
--- trunk/blender/release/io/export_obj.py 2009-09-27 08:54:58 UTC (rev 23506)
+++ trunk/blender/release/io/export_obj.py 2009-09-27 09:19:29 UTC (rev 23507)
@@ -48,6 +48,7 @@
# import math and other in functions that use them for the sake of fast Blender startup
# import math
import os
+import time
import bpy
import Mathutils
@@ -98,7 +99,7 @@
if copy_images:
abspath = image.get_export_path(dest_dir, False)
if not os.path.exists(abs_path):
- shutil.copy(bpy.sys.expandpath(image.filename), abs_path)
+ shutil.copy(image.get_abs_filename(), abs_path)
return rel
@@ -370,7 +371,7 @@
print('OBJ Export path: "%s"' % filename)
temp_mesh_name = '~tmp-mesh'
- time1 = bpy.sys.time()
+ time1 = time.clock()
# time1 = sys.time()
# scn = Scene.GetCurrent()
@@ -816,7 +817,7 @@
# else:
# print('\tError: "%s" could not be used as a base for an image path.' % filename)
- print("OBJ Export time: %.2f" % (bpy.sys.time() - time1))
+ print("OBJ Export time: %.2f" % (time.clock() - time1))
# print "OBJ Export time: %.2f" % (sys.time() - time1)
def do_export(filename, context,
Modified: trunk/blender/release/io/export_x3d.py
===================================================================
--- trunk/blender/release/io/export_x3d.py 2009-09-27 08:54:58 UTC (rev 23506)
+++ trunk/blender/release/io/export_x3d.py 2009-09-27 09:19:29 UTC (rev 23507)
@@ -779,7 +779,7 @@
pic = tex.image
# using .expandpath just in case, os.path may not expect //
- basename = os.path.basename(bpy.sys.expandpath(pic.filename))
+ basename = os.path.basename(pic.get_abs_filename())
pic = alltextures[i].image
# pic = alltextures[i].getImage()
Modified: trunk/blender/release/io/import_3ds.py
===================================================================
--- trunk/blender/release/io/import_3ds.py 2009-09-27 08:54:58 UTC (rev 23506)
+++ trunk/blender/release/io/import_3ds.py 2009-09-27 09:19:29 UTC (rev 23507)
@@ -939,7 +939,7 @@
# if BPyMessages.Error_NoFile(filename):
# return
- print('\n\nImporting 3DS: "%s"' % (bpy.sys.expandpath(filename)))
+ print('\n\nImporting 3DS: "%s"' % (filename))
# print('\n\nImporting 3DS: "%s"' % (Blender.sys.expandpath(filename)))
time1 = time.clock()
Modified: trunk/blender/source/blender/makesrna/intern/rna_image_api.c
===================================================================
--- trunk/blender/source/blender/makesrna/intern/rna_image_api.c 2009-09-27 08:54:58 UTC (rev 23506)
+++ trunk/blender/source/blender/makesrna/intern/rna_image_api.c 2009-09-27 09:19:29 UTC (rev 23507)
@@ -34,13 +34,15 @@
#include "RNA_define.h"
#include "RNA_types.h"
-#include "DNA_object_types.h"
-
#ifdef RNA_RUNTIME
+#include "BKE_image.h"
+#include "BKE_main.h"
#include "BKE_utildefines.h"
-#include "BKE_image.h"
+#include "DNA_image_types.h"
+#include "DNA_scene_types.h"
+
#include "MEM_guardedalloc.h"
/*
@@ -61,6 +63,17 @@
return path;
}
+char *rna_Image_get_abs_filename(Image *image, bContext *C)
+{
+ char *filename= MEM_callocN(FILE_MAX, "Image.get_abs_filename()");
+
+ BLI_strncpy(filename, image->name, FILE_MAXDIR + FILE_MAXFILE);
+ BLI_convertstringcode(filename, CTX_data_main(C)->name);
+ BLI_convertstringframe(filename, CTX_data_scene(C)->r.cfra);
+
+ return filename;
+}
+
#else
void RNA_api_image(StructRNA *srna)
@@ -76,6 +89,12 @@
RNA_def_property_flag(parm, PROP_REQUIRED);
parm= RNA_def_string(func, "path", "", 0, "", "Absolute export path.");
RNA_def_function_return(func, parm);
+
+ func= RNA_def_function(srna, "get_abs_filename", "rna_Image_get_abs_filename");
+ RNA_def_function_ui_description(func, "Get absolute filename.");
+ RNA_def_function_flag(func, FUNC_USE_CONTEXT);
+ parm= RNA_def_string_file_path(func, "abs_filename", NULL, 0, "", "Image/movie absolute filename.");
+ RNA_def_function_return(func, parm);
}
#endif
Modified: trunk/blender/source/blender/makesrna/intern/rna_object.c
===================================================================
--- trunk/blender/source/blender/makesrna/intern/rna_object.c 2009-09-27 08:54:58 UTC (rev 23506)
+++ trunk/blender/source/blender/makesrna/intern/rna_object.c 2009-09-27 09:19:29 UTC (rev 23507)
@@ -1414,6 +1414,11 @@
RNA_def_property_ui_text(prop, "Dupli Frames Off", "Recurring frames to exclude from the Dupliframes.");
RNA_def_property_update(prop, NC_OBJECT|ND_DRAW, "rna_Object_update");
+ prop= RNA_def_property(srna, "dupli_list", PROP_COLLECTION, PROP_NONE);
+ RNA_def_property_collection_sdna(prop, NULL, "duplilist", NULL);
+ RNA_def_property_struct_type(prop, "DupliObject");
+ RNA_def_property_ui_text(prop, "Dupli list", "Object duplis.");
+
/* time offset */
prop= RNA_def_property(srna, "time_offset", PROP_FLOAT, PROP_NONE|PROP_UNIT_TIME);
More information about the Bf-blender-cvs
mailing list