Page 1 of 1

Create layer keys with python

Posted: Wed May 09, 2007 11:55 am
by philippschmidt
Hello,

i have to import a sequence of obj-files. the standard-batch routine, that creates a new scene for every file is very bad for me, because the file are on animation.

my idea was to let the objects of each file appear for one frame in layer 1 and the rest of the time they should be in layer 2.

my big problem is now, that i didn't find a command to create a layer key (but nearly all other).

Thanks for your help!

greetings
philipp

Posted: Wed May 09, 2007 3:01 pm
by reD_Fox
Try the following link, I think it contains the information you need:
http://www.blender.org/documentation/24 ... tml#layers

Levi

didn't work

Posted: Thu May 10, 2007 11:56 am
by philippschmidt
Thanks for your answer, but it didn't work.
i could change the layer of an object, but it is changed for every frame, each time i change the layer.

here is my code:

Code: Select all

		#neu
		scn= Scene.New( stripExt(files[1]) )
		scn.makeCurrent()
		context = scn.getRenderingContext()
		#end neu
		for f in files:
			#alte szenenversion
			#scn= Scene.New( stripExt(f) )
			#scn.makeCurrent()
			
			
			
			new_objects = load_obj(sys.join(filepath, f),\
			  CLAMP_SIZE.val,\
			  CREATE_FGONS.val,\
			  CREATE_SMOOTH_GROUPS.val,\
			  CREATE_EDGES.val,\
			  SPLIT_OBJECTS.val,\
			  SPLIT_GROUPS.val,\
			  SPLIT_MATERIALS.val,\
			  IMAGE_SEARCH.val,\
			)
			
			context.currentFrame(frame-1)
			for ob in new_objects:
				ob.layers = [2]
					
			context.currentFrame(frame)
			for ob in new_objects:
				ob.layers = [1]
				
			context.currentFrame(frame+1)
			for ob in new_objects:
				ob.layers = [2]
			
			context.currentFrame(frame)
			
			print(scn.layers)
			
			frame = frame + 1

Posted: Thu May 10, 2007 3:54 pm
by reD_Fox
I'm sorry, I misunderstood your question. You can't animate objects changing layers using keys, via python or anything else. Once an object is said to be on a layer, it stays there until the user moves it (regardless of which frame it was on when moved).
However, you could use a Frame Change script link to animate this process using python:
http://wiki.blender.org/index.php/BSoD/ ... criptlinks
http://www.blender.org/documentation/24 ... ScriptLink
http://www.blender.org/documentation/24 ... .html#link
I'm not familiar enough with what you're attempting to do to give you much more direction than that, though.

Also, you might consider presenting your problems to the BlenderArtists.org site:
http://blenderartists.org/forum/forumdisplay.php?f=11
It is a bit more frequented, and you may get more and/or better help there.

Levi