Select scene from script

Hi all,
i want to know if it’s possible to select a scene from code…
I found two methods that take the current selected scene (bpy.context.scene() for bpy or gamelogic.getCurrentScene() for bge), but i’m going crazy to find a “select-scene-that-i-want” method!

Help http://www.blender.org/forum/images/smiles/icon_confused.gif

P.S.: i use blender 2.53

bge.logic.getSceneList()Gets a list of the current scenes loaded in the game engine.
Return type:list of bge.types.KX_Scene Note
Scenes in your blend file that have not been converted wont be in this list. This list will only contain scenes such as overlays scenes.

The problem is this…
I want to change (by script) the current frame to another and set there a keyframe, not in the current scene but in another one (that at the moment is not selected).

Using bpy i found method to change frame (bpy.ops.anim.change_frame()) and to set keyframe (bpy.ops.anim.keyframe_insert()) , but i don’t know how to make that changes onto the other scene!

Using bge i can use bge.logic.getSceneList() to select the scene, but i don’t know methods to change frame and set keyframes.

:spin:

I found the way…

bpy.data.scenes[‘SceneX’].set_frame(x) <---- to move to frame x

bpy.data.scenes[‘SceneX’].keyframe_insert() <---- to insert a keyframe *

*i don’t understand what argument is Data Path!
Here is the description:

keyframe_insert(data_path, index=-1, frame=bpy.context.scene.frame_current, group=“”)
Insert a keyframe on the property given, adding fcurves and animation data when necessary.

Parameters:

  • data_path (string) – path to the property to key, analogous to the fcurve’s data path.
  • index (int) – array index of the property to key. Defaults to -1 which will key all indicies or a single channel if the property is not an array.
  • frame (float) – The frame on which the keyframe is inserted, defaulting to the current frame.
  • group (str) – The name of the group the F-Curve should be added to if it doesn’t exist yet.

What is “path to the property to key”?

No one can help me?

You are doing Blender things in BGE. As far as I know the BGE does not use frames from Blender.
Scripting for Blender is different to scripting for BGE.

Are you sure you want to ask this in the GameEngine forum? I can move the thread to the Python & Plugins forum. I’m pretty sure you will get help there really quick.

I don’t know in effect :smiley:
I want to create a dynamic animation in BGE, and the only way i understood to do that it’s through frames and FCurve actuator…
For this reason i use bpy mixed with bge scripting in bge (usually all bpy code works refreshing the scene in bge); but if it’s another way (through bge) to have the same results, i wish you tell me :slight_smile: