Create layer keys with python

Scripting in Blender with Python, and working on the API

Moderators: jesterKing, stiv

Post Reply
philippschmidt
Posts: 0
Joined: Wed May 09, 2007 11:36 am

Create layer keys with python

Post by philippschmidt » Wed May 09, 2007 11:55 am

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

reD_Fox
Posts: 0
Joined: Sat Mar 12, 2005 2:56 pm
Location: Abilene, KS

Post by reD_Fox » Wed May 09, 2007 3:01 pm

Try the following link, I think it contains the information you need:
http://www.blender.org/documentation/24 ... tml#layers

Levi
A three-legged stool never wobbles.

philippschmidt
Posts: 0
Joined: Wed May 09, 2007 11:36 am

didn't work

Post by philippschmidt » Thu May 10, 2007 11:56 am

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

reD_Fox
Posts: 0
Joined: Sat Mar 12, 2005 2:56 pm
Location: Abilene, KS

Post by reD_Fox » Thu May 10, 2007 3:54 pm

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
A three-legged stool never wobbles.

Post Reply