~siretart/ubuntu/utopic/blender/libav10

« back to all changes in this revision

Viewing changes to release/scripts/addons_contrib/oscurart_tools/oscurart_files.py

  • Committer: Reinhard Tartler
  • Date: 2014-05-31 01:50:05 UTC
  • mfrom: (14.2.27 sid)
  • Revision ID: siretart@tauware.de-20140531015005-ml6druahuj82nsav
mergeĀ fromĀ debian

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
import bpy
 
2
import math
 
3
import sys
 
4
import os
 
5
import stat
 
6
import bmesh
 
7
import time
 
8
import random
 
9
 
 
10
##---------------------------RELOAD IMAGES------------------
 
11
class reloadImages (bpy.types.Operator):
 
12
    bl_idname = "image.reload_images_osc"
 
13
    bl_label = "Reload Images"
 
14
    bl_options = {"REGISTER", "UNDO"}
 
15
    def execute(self,context):
 
16
        for imgs in bpy.data.images:
 
17
            imgs.reload()
 
18
        return {'FINISHED'}
 
19
 
 
20
 
 
21
##------------------------ SAVE INCREMENTAL ------------------------
 
22
 
 
23
class saveIncremental(bpy.types.Operator):
 
24
    bl_idname = "file.save_incremental_osc"
 
25
    bl_label = "Save Incremental File"
 
26
    bl_options = {"REGISTER", "UNDO"}
 
27
    def execute(self, context):     
 
28
        filepath = bpy.data.filepath        
 
29
        if filepath.count("_v"):
 
30
            strnum = filepath.rpartition("_v")[-1].rpartition(".blend")[0]
 
31
            intnum = int(strnum)
 
32
            modnum = strnum.replace(str(intnum),str(intnum+1))    
 
33
            output = filepath.replace(strnum,modnum)
 
34
            basename = os.path.basename(filepath)            
 
35
            bpy.ops.wm.save_as_mainfile(filepath=os.path.join(os.path.dirname(filepath),"%s_v%s.blend" % (basename.rpartition("_v")[0],str(modnum))))
 
36
 
 
37
        else:
 
38
            output = filepath.rpartition(".blend")[0]+"_v01"
 
39
            bpy.ops.wm.save_as_mainfile(filepath=output)         
 
40
        
 
41
        return {'FINISHED'}
 
42
 
 
43
##------------------------ REPLACE FILE PATHS ------------------------
 
44
 
 
45
bpy.types.Scene.oscSearchText = bpy.props.StringProperty(default="Search Text")
 
46
bpy.types.Scene.oscReplaceText = bpy.props.StringProperty(default="Replace Text")
 
47
 
 
48
class replaceFilePath(bpy.types.Operator):
 
49
    bl_idname = "file.replace_file_path_osc"
 
50
    bl_label = "Replace File Path"
 
51
    bl_options = {"REGISTER", "UNDO"}
 
52
    def execute(self, context):
 
53
        TEXTSEARCH = bpy.context.scene.oscSearchText
 
54
        TEXTREPLACE = bpy.context.scene.oscReplaceText
 
55
 
 
56
        for image in bpy.data.images:
 
57
            image.filepath = image.filepath.replace(TEXTSEARCH,TEXTREPLACE)
 
58
 
 
59
        return {'FINISHED'}
 
 
b'\\ No newline at end of file'