Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender-addons.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGreg Zaal <gregzzmail@gmail.com>2014-08-25 23:09:11 +0400
committerGreg Zaal <gregzzmail@gmail.com>2014-08-25 23:09:11 +0400
commita6f74e91b970a228f628df6229b0b4b34efbe30e (patch)
tree436dceff46f871ddc052f4b248aad3bb4c79d5af /node_efficiency_tools.py
parent09dd79eddd8e57951ae9cfb3237e58f40c86138c (diff)
Fix T41022: [Node Wrangler] Image sequence import
Failed when importing an image sequence where the start frame was something other than 1.
Diffstat (limited to 'node_efficiency_tools.py')
-rw-r--r--node_efficiency_tools.py37
1 files changed, 17 insertions, 20 deletions
diff --git a/node_efficiency_tools.py b/node_efficiency_tools.py
index 48d1d501..35b17f19 100644
--- a/node_efficiency_tools.py
+++ b/node_efficiency_tools.py
@@ -19,7 +19,7 @@
bl_info = {
"name": "Node Wrangler (aka Nodes Efficiency Tools)",
"author": "Bartek Skorupa, Greg Zaal",
- "version": (3, 11),
+ "version": (3, 12),
"blender": (2, 71, 0),
"location": "Node Editor Properties Panel or Ctrl-Space",
"description": "Various tools to enhance and speed up node-based workflow",
@@ -36,6 +36,7 @@ from bpy_extras.io_utils import ImportHelper
from mathutils import Vector
from math import cos, sin, pi, hypot
from os import listdir
+from glob import glob
#################
# rl_outputs:
@@ -2774,39 +2775,31 @@ class NWAddSequence(Operator, ImportHelper):
self.report({'ERROR'}, "Unsupported Node Tree type!")
return {'CANCELLED'}
- # if last digit isn't a number, it's not a sequence
without_ext = '.'.join(filename.split('.')[:-1])
+
+ # if last digit isn't a number, it's not a sequence
if without_ext[-1].isdigit():
without_ext = without_ext[:-1] + '1'
else:
self.report({'ERROR'}, filename+" does not seem to be part of a sequence")
return {'CANCELLED'}
+
+ extension = filename.split('.')[-1]
reverse = without_ext[::-1] # reverse string
- newreverse = ""
- non_numbers = ""
+
count_numbers = 0
- stop = False
for char in reverse:
- if char.isdigit() and stop==False:
+ if char.isdigit():
count_numbers += 1
- newreverse += '0' # replace numbers of image sequence with zeros
else:
- stop = True
- newreverse += char
- non_numbers = char + non_numbers
+ break
- newreverse = '1' + newreverse[1:]
- without_ext = newreverse[::-1] # reverse string
+ without_num = without_ext[:count_numbers*-1]
- # print (without_ext+'.'+filename.split('.')[-1])
- # print (non_numbers)
- extension = filename.split('.')[-1]
+ files = sorted(glob(directory + without_num + "[0-9]"*count_numbers + "." + extension))
- num_frames = len(list(f for f in listdir(directory) if f.startswith(non_numbers)))
-
- for x in range(count_numbers):
- non_numbers += '#'
+ num_frames = len(files)
nodes_list = [node for node in nodes]
if nodes_list:
@@ -2821,14 +2814,18 @@ class NWAddSequence(Operator, ImportHelper):
xloc = 0
yloc = 0
+ name_with_hashes = without_num + "#"*count_numbers + '.' + extension
+
node = nodes.new(node_type)
node.location.x = xloc
node.location.y = yloc + 110
- node.label = non_numbers+'.'+extension
+ node.label = name_with_hashes
img = bpy.data.images.load(directory+(without_ext+'.'+extension))
img.source = 'SEQUENCE'
+ img.name = name_with_hashes
node.image = img
+ node.frame_offset = int(files[0][len(without_num)+len(directory):-1*(len(extension)+1)]) - 1 # separate the number from the file name of the first file
if context.space_data.node_tree.type == 'SHADER':
node.image_user.frame_duration = num_frames
else: