Set the first and end frame by script

Hello,

I have a rather simple question for you.
I have imported some models from make human and with the help of mocap tool for importing .bvh files, I have imported some movements.

I would like to set the start frame and the end frame (through script), but I am a bit confused. I have thought two ways that I could do that.

  1. Set through the mocap tool. So I use the following code

import bpy
import os

scn = Scene.GetCurrent()
context = scn.MhxStartFrame(1)
but I get the error name 'Scene' is not defined
  1. Maybe I could do it through NLA Editor after it is imported?
    Have you any clue? Because I haven’t find so far!

Thanks!

You can do it this way.


import bpy

bpy.data.scenes[0].frame_start = 2
bpy.data.scenes[0].frame_end = 251

If you’re just trying to set the start/end frames for the scene, you can just use this.

import bpy

scn = bpy.context.scene
scn.frame_start = 50
scn.frame_end = 200

edit. Ha, Atom beat me to it!

Well, I see what you are saying, but by that I set the first and last frame of the current scene, right?
And afterwards, I can see the result in the timeline. The thing is that I would like to import 3 different .bvh files and place them one after another. That is why, for each one, I would like to set the frame “MhxStartFrame” and the End Frame.

I don’t know if I am understood:)

Thanks both of you by the way, because I have to solve this problem, this afternoon:)

Well, I got it


import bpy
scn = bpy.context.scene
scn.MhxStartFrame = 100
scn.MhxEndFrame = 200

but still the result is not the desirable, meaning, that I want to see my action starting from Frame 100, and this script in not what I am doing.

I haven’t used the Makehuman importer, but when you’re defining:
scn = bpy.context.scene
scn.MhxStartFrame

There is no MhxStartFrame in the blender api, that addon might support it. But like I said, i haven’t used the Makehuman inmport. Maybe upload a few sample mhx files to test.

I know, that was my problem from the beginning, but this one works:)
Still, this wasn’t what I was looking for…I found the solution with the help of NLA Editor:)

Thanks