How to get the frame count of a scene

Hi,

I would like to obtain, with a script, the total number of frames of a scene.

I tried with the following two primitives, but didn't get the right value:

  • Scene.getPlayRange()
  • Scene.getAnimRange()

 

 

Comments

  • Willy2Willy2 Posts: 165

    Hi,

    I would like to obtain, with a script, the total number of frames of a scene.

    I tried with the following two primitives, but didn't get the right value:

    • Scene.getPlayRange()
    • Scene.getAnimRange()

     

     

  • It's a Daz-ism. The units are "ticks" which is 1/4800 th of a second.

  • Willy2Willy2 Posts: 165

    I am not interested in the intrinsic meaning of this variable.
    I want to get this value to use in a for loop.
    On the attached image, it is equal to 215.

     

  • Willy2 said:

    I am not interested in the intrinsic meaning of this variable.
    I want to get this value to use in a for loop.
    On the attached image, it is equal to 215.

    To my knowledge, DS doesn't reckon time in terms of frames, but rather ticks. You have to be interested in the intrinsic meaning of this variable to convert from the ticks returned by the time functions to frames. Something like:

    auto timeStep = dzScene->getTimeStep();
    auto start = dzScene->getPlayRange().getStart() / timeStep;
    auto end = dzScene->getPlayRange().getEnd() / timeStep;

    But you are asking a script question in the SDK forum.

  • Willy2Willy2 Posts: 165
    edited May 2022

    I got this value in the following way:

    var timestep = Scene.getTimeStep()var range_end = Scene.getPlayRange().end/timestepprint(range_end);

    Thanks

    Post edited by Richard Haseltine on
  • algovincianalgovincian Posts: 2,575

    Hopefully, this simple script should demonstrate how it works:

    print( "Time Step: " + Scene.getTimeStep() );
    print( "Start Time: " + Scene.getPlayRange().start );
    print( "End Time: " + Scene.getPlayRange().end );

    var startFrame = Scene.getPlayRange().start / Scene.getTimeStep();
    var endFrame = Scene.getPlayRange().end / Scene.getTimeStep();

    print( "Start Frame: " + startFrame );
    print( "End Frame: " + endFrame );

    var totalFrames = endFrame - startFrame;

    print( "Total Frames: " + totalFrames );

    HTH.

    - Greg

  • Richard HaseltineRichard Haseltine Posts: 96,718

    Threads merged.

Sign In or Register to comment.