Pre-comp layer(s) and cropping depending on its size

What type of scripts do you need?

Moderator: byronnash

Post Reply
gcp
Posts: 2
Joined: March 15th, 2022, 11:12 am

Hello everyone! Hope you can help on this.

I Have my desings made on PS, I import it to AE and I start creating tons of pre-comps.
But then I have to go one by one in order to crop them to fit the layer(s) boundaries.

I would like to have an script to automatate this.
Let's say that the most common cases are:

1- Just 1 layer > pre-comp and sizing it to its boundaries.
2 -More than 1 layer > pre-comp and sizing to their boundaries in conjunction.

When the precomp its made it should remains the original position on the main comp.

And finally if it could have a place where set up extra margins will be great!

I leave the Dialog code I picture to use (I made it with https://scriptui.joonas.me/) Feel free to suggest!

Thank you so much in advance!

/*
Code for Import https://scriptui.joonas.me — (Triple click to select):
{"activeId":21,"items":{"item-0":{"id":0,"type":"Dialog","parentId":false,"style":{"enabled":true,"varName":null,"windowType":"Palette","creationProps":{"su1PanelCoordinates":false,"maximizeButton":false,"minimizeButton":false,"independent":false,"closeButton":true,"borderless":false,"resizeable":false},"text":"Pre-Comp","preferredSize":[0,0],"margins":16,"orientation":"row","spacing":10,"alignChildren":["center","top"]}},"item-4":{"id":4,"type":"Group","parentId":19,"style":{"enabled":true,"varName":null,"preferredSize":[0,0],"margins":0,"orientation":"row","spacing":10,"alignChildren":["left","center"],"alignment":null}},"item-14":{"id":14,"type":"Panel","parentId":0,"style":{"enabled":true,"varName":null,"creationProps":{"borderStyle":"etched","su1PanelCoordinates":false},"text":"Margin","preferredSize":[0,0],"margins":10,"orientation":"column","spacing":10,"alignChildren":["left","top"],"alignment":"center"}},"item-18":{"id":18,"type":"Button","parentId":4,"style":{"enabled":true,"varName":"bgbutton","text":"Pre-Comp","justify":"center","preferredSize":[0,0],"alignment":null,"helpTip":null}},"item-19":{"id":19,"type":"Panel","parentId":0,"style":{"enabled":true,"varName":null,"creationProps":{"borderStyle":"etched","su1PanelCoordinates":false},"text":"","preferredSize":[0,0],"margins":10,"orientation":"column","spacing":10,"alignChildren":["left","top"],"alignment":null}},"item-21":{"id":21,"type":"EditText","parentId":14,"style":{"enabled":true,"varName":null,"creationProps":{"noecho":false,"readonly":false,"multiline":false,"scrollable":false,"borderless":false,"enterKeySignalsOnChange":false},"softWrap":false,"text":"15","justify":"left","preferredSize":[60,0],"alignment":null,"helpTip":null}}},"order":[0,14,21,19,4,18],"settings":{"importJSON":true,"indentSize":false,"cepExport":false,"includeCSSJS":true,"showDialog":true,"functionWrapper":false,"afterEffectsDockable":false,"itemReferenceList":"None"}}
*/

// PALETTE
// =======
var palette = new Window("palette");
palette.text = "Pre-Comp";
palette.orientation = "row";
palette.alignChildren = ["center","top"];
palette.spacing = 10;
palette.margins = 16;

// PANEL1
// ======
var panel1 = palette.add("panel", undefined, undefined, {name: "panel1"});
panel1.text = "Margin";
panel1.orientation = "column";
panel1.alignChildren = ["left","top"];
panel1.spacing = 10;
panel1.margins = 10;
panel1.alignment = ["center","center"];

var edittext1 = panel1.add('edittext {properties: {name: "edittext1"}}');
edittext1.text = "15";
edittext1.preferredSize.width = 60;

// PANEL2
// ======
var panel2 = palette.add("panel", undefined, undefined, {name: "panel2"});
panel2.orientation = "column";
panel2.alignChildren = ["left","top"];
panel2.spacing = 10;
panel2.margins = 10;

// GROUP1
// ======
var group1 = panel2.add("group", undefined, {name: "group1"});
group1.orientation = "row";
group1.alignChildren = ["left","center"];
group1.spacing = 10;
group1.margins = 0;

var bgbutton = group1.add("button", undefined, undefined, {name: "bgbutton"});
bgbutton.text = "Pre-Comp";

palette.show();

Attachments
dialog.PNG
dialog.PNG (126.75 KiB) Viewed 8017 times
Post Reply