forked from bartvdbraak/blender
Added Image.get_abs_filename() and updated scripts to use it. This removes the necessity of bpy.sys.expandpath().
Added missing Object.dupli_list.
This commit is contained in:
parent
bd7dc77884
commit
4363132788
@ -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)
|
||||
|
||||
|
@ -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,
|
||||
|
@ -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()
|
||||
|
@ -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()
|
||||
|
@ -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
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user