From 43631327887d3000be0743be8ac632f25401078f Mon Sep 17 00:00:00 2001 From: Arystanbek Dyussenov Date: Sun, 27 Sep 2009 09:19:29 +0000 Subject: Added Image.get_abs_filename() and updated scripts to use it. This removes the necessity of bpy.sys.expandpath(). Added missing Object.dupli_list. --- release/io/export_fbx.py | 4 ++-- release/io/export_obj.py | 7 ++++--- release/io/export_x3d.py | 2 +- release/io/import_3ds.py | 2 +- source/blender/makesrna/intern/rna_image_api.c | 25 ++++++++++++++++++++++--- source/blender/makesrna/intern/rna_object.c | 5 +++++ 6 files changed, 35 insertions(+), 10 deletions(-) diff --git a/release/io/export_fbx.py b/release/io/export_fbx.py index 3515170528f..aa65473b8d6 100644 --- a/release/io/export_fbx.py +++ b/release/io/export_fbx.py @@ -94,6 +94,7 @@ def copy_file(source, dest): 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 @@ def write(filename, batch_objects = None, \ 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) diff --git a/release/io/export_obj.py b/release/io/export_obj.py index bd323b6586a..e2ac78798bd 100644 --- a/release/io/export_obj.py +++ b/release/io/export_obj.py @@ -48,6 +48,7 @@ will be exported as mesh data. # 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 @@ def write_mtl(scene, filename, copy_images): 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 @@ def write(filename, objects, scene, 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 @@ def write(filename, objects, scene, # 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, diff --git a/release/io/export_x3d.py b/release/io/export_x3d.py index 3661d78a343..f23ccf8d2dc 100644 --- a/release/io/export_x3d.py +++ b/release/io/export_x3d.py @@ -779,7 +779,7 @@ class x3d_class: 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() diff --git a/release/io/import_3ds.py b/release/io/import_3ds.py index d57911df83c..99825471764 100644 --- a/release/io/import_3ds.py +++ b/release/io/import_3ds.py @@ -939,7 +939,7 @@ def load_3ds(filename, context, IMPORT_CONSTRAIN_BOUNDS=10.0, IMAGE_SEARCH=True, # 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() diff --git a/source/blender/makesrna/intern/rna_image_api.c b/source/blender/makesrna/intern/rna_image_api.c index 25c764b8823..2bb7905fc03 100644 --- a/source/blender/makesrna/intern/rna_image_api.c +++ b/source/blender/makesrna/intern/rna_image_api.c @@ -34,12 +34,14 @@ #include "RNA_define.h" #include "RNA_types.h" -#include "DNA_object_types.h" - #ifdef RNA_RUNTIME -#include "BKE_utildefines.h" #include "BKE_image.h" +#include "BKE_main.h" +#include "BKE_utildefines.h" + +#include "DNA_image_types.h" +#include "DNA_scene_types.h" #include "MEM_guardedalloc.h" @@ -61,6 +63,17 @@ static char *rna_Image_get_export_path(Image *image, char *dest_dir, int rel) 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 @@ void RNA_api_image(StructRNA *srna) 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 diff --git a/source/blender/makesrna/intern/rna_object.c b/source/blender/makesrna/intern/rna_object.c index 76d9e077a18..5c665c0d730 100644 --- a/source/blender/makesrna/intern/rna_object.c +++ b/source/blender/makesrna/intern/rna_object.c @@ -1414,6 +1414,11 @@ static void rna_def_object(BlenderRNA *brna) 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); -- cgit v1.2.3