python blender-list-files-of-loaded-image-sequence.py
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了python blender-list-files-of-loaded-image-sequence.py相关的知识,希望对你有一定的参考价值。
# for http://blender.stackexchange.com/q/73858/3710
import bpy
import os
def image_sequence_resolve(operator, context):
filepath = context.space_data.clip.filepath
filepath_full = bpy.path.abspath(filepath)
basedir, filename = os.path.split(filepath_full)
filename_noext, ext = os.path.splitext(filename)
from string import digits
if isinstance(filepath, bytes):
digits = digits.encode()
filename_nodigits = filename_noext.rstrip(digits)
if len(filename_nodigits) == len(filename_noext):
# input isn't from a sequence
return []
files = os.listdir(basedir)
return [
os.path.join(basedir, f)
for f in files
if f.startswith(filename_nodigits) and
f.endswith(ext) and
f[len(filename_nodigits):-len(ext) if ext else -1].isdigit()]
class CLIP_OT_image_sequence(bpy.types.Operator):
bl_idname="clip.image_sequence"
bl_label="List Files of Image Sequence"
@classmethod
def poll(cls, context):
spc = context.space_data
return (spc.type == 'CLIP_EDITOR') and spc.clip
def execute(self, context):
spc = context.space_data
if spc.clip.source == 'SEQUENCE':
print(image_sequence_resolve(self, context))
self.report({"INFO"}, "Image Sequence: {}".format(spc.clip.name))
else:
self.report({"INFO"}, "Not a sequence")
return {'FINISHED'}
def register():
bpy.utils.register_class(CLIP_OT_image_sequence)
def unregister():
bpy.utils.unregister_class(CLIP_OT_image_sequence)
if __name__ == "__main__":
register()
以上是关于python blender-list-files-of-loaded-image-sequence.py的主要内容,如果未能解决你的问题,请参考以下文章
Python代写,Python作业代写,代写Python,代做Python
Python开发
Python,python,python
Python 介绍
Python学习之认识python
python初识