Copy link to clipboard
Copied
Is a script that create a compositing with 3 layers, all works, but can't make to open the compositing
I tried different codes for internet app.project.activeItem and app.project.numItems and no one open a compositing
//*
````
function createCompositionWithShapes() { app.beginUndoGroup("Create Composition with Shapes"); // Create a new composition var comp = app.project.items.addComp("ColorComp", 1920, 1080, 1, 10, 30); // Create shape layers var shapes = ["Red", "Green", "Blue"]; var colors = [[1, 0, 0], [0, 1, 0], [0, 0, 1]]; // RGB colors for Red, Green, Blue for (var i = 0; i < shapes.length; i++) { var shapeLayer = comp.layers.addShape(); shapeLayer.name = shapes[i]; // Create a shape group var shapeGroup = shapeLayer.property("Contents").addProperty("ADBE Vector Group"); var shape = shapeGroup.property("Contents").addProperty("ADBE Vector Shape - Ellipse"); shape.property("Size").setValue([200, 200]); // Set size of the shape // Create a fill for the shape var fill = shapeGroup.property("Contents").addProperty("ADBE Vector Graphic - Fill"); fill.property("Color").setValue(colors[i]); // Set color for the fill // Position the shape layer shapeLayer.transform.position.setValue([comp.width / 2, comp.height / 2 + i * 150]); } app.endUndoGroup(); } // Run the function to create the composition createCompositionWithShapes(); // Ensure the composition is visible in the viewer var viewerFound = false; for (var i = 0; i < app.project.viewers.length; i++) { var viewer = app.project.viewers[i]; if (viewer && viewer.type === ViewerType.VIEWER_COMPOSITION) { viewer.setActive(); viewerFound = true; break; } } ````
*//
You can use openInViewer();
function createCompositionWithShapes() {
app.beginUndoGroup("Create Composition with Shapes");
// Create a new composition
var comp = app.project.items.addComp("ColorComp", 1920, 1080, 1, 10, 30);
// Open the comp
comp.openInViewer();
// Create shape layers
var shapes = ["Red", "Green", "Blue"];
var colors = [
[1, 0, 0],
[0, 1, 0],
[0, 0, 1]
]; // RGB colors for Red, Green, Blue
for (var i = 0; i < shapes.length; i++) {
var shape
...
Copy link to clipboard
Copied
You can use openInViewer();
function createCompositionWithShapes() {
app.beginUndoGroup("Create Composition with Shapes");
// Create a new composition
var comp = app.project.items.addComp("ColorComp", 1920, 1080, 1, 10, 30);
// Open the comp
comp.openInViewer();
// Create shape layers
var shapes = ["Red", "Green", "Blue"];
var colors = [
[1, 0, 0],
[0, 1, 0],
[0, 0, 1]
]; // RGB colors for Red, Green, Blue
for (var i = 0; i < shapes.length; i++) {
var shapeLayer = comp.layers.addShape();
shapeLayer.name = shapes[i];
// Create a shape group
var shapeGroup = shapeLayer.property("Contents").addProperty("ADBE Vector Group");
var shape = shapeGroup.property("Contents").addProperty("ADBE Vector Shape - Ellipse");
shape.property("Size").setValue([200, 200]); // Set size of the shape
// Create a fill for the shape
var fill = shapeGroup.property("Contents").addProperty("ADBE Vector Graphic - Fill");
fill.property("Color").setValue(colors[i]); // Set color for the fill
// Position the shape layer
shapeLayer.transform.position.setValue([comp.width / 2, comp.height / 2 + i * 150]);
}
app.endUndoGroup();
}
// Run the function to create the composition
createCompositionWithShapes();
Copy link to clipboard
Copied
It works, thanks a lot