[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [13482] trunk/blender/release/scripts/ bpymodules/blend2renderinfo.py: Standalone reads a list of scene, start frame, end frame from blend files without having to load them in blender.

Campbell Barton ideasman42 at gmail.com
Wed Jan 30 17:16:40 CET 2008


Revision: 13482
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=13482
Author:   campbellbarton
Date:     2008-01-30 17:16:38 +0100 (Wed, 30 Jan 2008)

Log Message:
-----------
Standalone reads a list of scene, start frame, end frame from blend files without having to load them in blender.
Scenes must be tagged to render, (old render daemon button) but selecting scenes in the data browser (shoft+f4) sets this also.

Using this script to generate jobs for the renderfarm much faster then loading blender.

Added Paths:
-----------
    trunk/blender/release/scripts/bpymodules/blend2renderinfo.py

Added: trunk/blender/release/scripts/bpymodules/blend2renderinfo.py
===================================================================
--- trunk/blender/release/scripts/bpymodules/blend2renderinfo.py	                        (rev 0)
+++ trunk/blender/release/scripts/bpymodules/blend2renderinfo.py	2008-01-30 16:16:38 UTC (rev 13482)
@@ -0,0 +1,92 @@
+#!/usr/bin/python
+
+# --------------------------------------------------------------------------
+# ***** BEGIN GPL LICENSE BLOCK *****
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software Foundation,
+# Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+#
+# ***** END GPL LICENCE BLOCK *****
+# --------------------------------------------------------------------------
+
+import sys, struct
+
+# In Blender, selecting scenes in the databrowser (shift+f4) will tag for rendering.
+
+# This struct wont change according to ton.
+# Note that the size differs on 32/64bit
+'''
+typedef struct BHead {
+	int code, len;
+	void *old;
+	int SDNAnr, nr;
+} BHead;
+'''
+
+
+def read_blend_rend_chunk(path):
+	file = open(path, 'rb')
+	
+	if file.read(len('BLENDER')) != 'BLENDER':
+		return
+	
+	# 
+	if file.read(1) == '-':
+		is64bit = True
+	else: # '_'
+		is64bit = False
+
+	if file.read(1) == 'V':
+		isBigEndian = True # ppc
+	else: # 'V'
+		isBigEndian = False # x86
+	
+	
+	# Now read the bhead chunk!!!
+	file.read(3) # skip the version
+	
+	while file.read(4) == 'REND':
+	
+		if is64bit:		sizeof_bhead = sizeof_bhead_left = 24 # 64bit
+		else:			sizeof_bhead = sizeof_bhead_left = 20 # 32bit
+	
+		sizeof_bhead_left -= 4
+		
+		if isBigEndian:	rend_length = struct.unpack('>i', file.read(4))[0]
+		else:			rend_length = struct.unpack('<i', file.read(4))[0]
+		
+		sizeof_bhead_left -= 4
+		
+		# We dont care about the rest of the bhead struct
+		sizeof_bhead_left, file.read(sizeof_bhead_left)
+		
+		# Now we want the scene name, start and end frame. this is 32bites long
+		#file.read(sizeof_bhead_left)
+		
+		if isBigEndian:	start_frame, end_frame = struct.unpack('>2i', file.read(8))
+		else:			start_frame, end_frame = struct.unpack('<2i', file.read(8))
+		
+		scene_name = file.read(24)
+		scene_name = scene_name[ : scene_name.index('\0') ]
+		
+		return start_frame, end_frame, scene_name
+
+def main():
+	for arg in sys.argv[1:]:
+		if arg.lower().endswith('.blend'):
+			print read_blend_rend_chunk(arg)
+
+if __name__ == '__main__':
+	main()
+





More information about the Bf-blender-cvs mailing list