Support > Scripts > Create a new Scene and its Contents II

ToonzScript Code

// Create a function called addLevel capable of inserting a level into a scene and transforming it
// the addLevel function accepts the following parameters
// scene : the scene identifier
// column : index of the column where the level has to be exposed
// name : name of the new level
// sourceLevel : starting level
// transform : transformation to apply



function addLevel(scene, column, name, sourceLevel, transform) {
    level = scene.newLevel("Vector", name);
    fids = sourceLevel.getFrameIds();
    for(i=0; i<sourceLevel.frameCount;i++)
    {
        image = sourceLevel.getFrameByIndex(i);
        imb = new ImageBuilder();
        level.setFrame(fids[i], imb.add(image, transform).image);
        scene.setCell(i, column, level, fids[i]);
    }
}

dir1 = "C:\\Toonz 7.0 stuff\\SCRIPT IMAGES IN\\";
dir2 = "C:\\Toonz 7.0 stuff\\SCRIPT IMAGES OUT\\";
dir3 = "C:\\Toonz 7.0 stuff\\projects\\Plastic\\scenes\\";

scene = new Scene();
addLevel(scene,9,"Conv1",new Level(dir1+"B.pli"), new Transform().translate(0.1,0.5).rotate(45).scale(0.5));
addLevel(scene,10,"Conv2",new Level(dir1+"C.pli"), new Transform().rotate(180));
scene.save(dir3 + "rif4.tnz");