Added Image.get_abs_filename() and updated scripts to use it. This removes the necess...
authorArystanbek Dyussenov <arystan.d@gmail.com>
Sun, 27 Sep 2009 09:19:29 +0000 (09:19 +0000)
committerArystanbek Dyussenov <arystan.d@gmail.com>
Sun, 27 Sep 2009 09:19:29 +0000 (09:19 +0000)
Added missing Object.dupli_list.

release/io/export_fbx.py
release/io/export_obj.py
release/io/export_x3d.py
release/io/import_3ds.py
source/blender/makesrna/intern/rna_image_api.c
source/blender/makesrna/intern/rna_object.c

index 3515170528f5e0bd67bc48bb1c3a979f47e88fb8..aa65473b8d65a5fa157d0e83fd32023f18f07287 100644 (file)
@@ -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)
 
index bd323b6586a40409ce0c899a296c0a44b56bdb09..e2ac78798bd75c1f339af52bc1b88919dd33ce4c 100644 (file)
@@ -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, 
index 3661d78a34387fc9fdfdba1726d9246dac46cfe4..f23ccf8d2dc6578a94a3235003295e0a5ef4cf3b 100644 (file)
@@ -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()
index d57911df83c2deff5a3b61dd847a50b6224c263d..99825471764e792c40462142ac5a160f3ef1472a 100644 (file)
@@ -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()
index 25c764b8823a1210672648178cc64b575dd555f8..2bb7905fc034f40a617cf144da7d6f78fb6f68c8 100644 (file)
 #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
index 76d9e077a18521bd740eeca67817f6606b05e7d7..5c665c0d730c3a5b4a0ebbd0c873c3eb9e800dbd 100644 (file)
@@ -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);