ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

setup composition height and width via expression

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Ron Grev
setup composition height and width via expression
on Dec 13, 2017 at 8:14:36 am

Hello everybody,

because i hve to resize many many comps according to its content it would be geat
to ajust the comp.height ahnd comp.width over expression (e.g. slider)
is it possible in AE?

Thanks Ronald


Return to posts index

Dan Ebberts
Re: setup composition height and width via expression
on Dec 13, 2017 at 4:44:13 pm

No, expressions can only control the value of the property hosting the expression.

Dan



Return to posts index

Rainier Raydán
Re: setup composition height and width via expression
on Dec 13, 2017 at 6:54:32 pm

Hi Ron!

You can do that only with a Script. You can use mine



{
function myScript(thisObj) {
function myScript_buildUI(thisObj) {
var myPanel = (thisObj instanceof Panel) ? thisObj : new Window("palette", "compSettings RR V01", [0, 0, 300, 300]);

res = "group{orientation:'row', alignment:['fill', 'fill'], alignChildren:['fill', 'fill'],\
mainGroup: Group{orientation:'column', alignment:['fill', 'fill'], alignChildren:['fill', 'fill'],\
sizeGroup: Panel{text:'Panel Name',orientation:'row', alignment:['fill', 'fill'], alignChildren:['fill', 'fill'],\
widthText: StaticText{text:'Width'},\
editWidth: EditText{text:'', characters: 4},\
heightText: StaticText{text:'Height'},\
editHeight: EditText{text:'', characters: 4},\
},\
},\
btnGroup: Group{orientation:'column', alignment:['top', 'top'], alignChildren:['fill', 'fill'],\
runBtn: Button{text:'Run'},\
},\
},\
}"


// Adds resource string to panel
myPanel.grp = myPanel.add(res);

// VARIABLES
var proj = app.project;
var curWidth = myPanel.grp.mainGroup.sizeGroup.editWidth;
var curHeight = myPanel.grp.mainGroup.sizeGroup.editHeight;

var runButton = myPanel.grp.btnGroup.runBtn;

// Assign function to UI elements

runButton.onClick = function (){
var selectedArray = itemSelection();
if(!itemSelection()){
alert("Select at least one composition.");
}else{
app.beginUndoGroup("changeCompWH");
for(a=0;a0){
return itemAry;
}else{
return null;
}
}

// Setup panel sizing and make panel resizable
myPanel.layout.layout(true);
myPanel.grp.minimumSize = myPanel.grp.size;
myPanel.layout.resize();
myPanel.onResizing = myPanel.onResize = function () {this.layout.resize();}

return myPanel;
}

// Build script panel
var myScriptPal = myScript_buildUI(thisObj);

if ((myScriptPal != null) && (myScriptPal instanceof Window)) {
myScriptPal.center();
myScriptPal.show();
}
}

// Execute script
myScript(this);
}







Just put the dimension you want, select one or multiple comps and click the Run buttom.

If you want a slider (I do not recomend this) you can change the editText for a slider in the code.

P.D. : Copy the code into a notepad and save it with .jsx extension. Then open it with File/Scrips/Run Script File...

Bye!


Return to posts index


Ron Grev
Re: setup composition height and width via expression
on Dec 14, 2017 at 8:36:24 pm

Hello Dan, hello Raineier,

thanks for response.
The Script-Version seems to be good for project.
But when i execute the script i alwas get the warning:

Unable to execute at line 40. Expected: ;

for(a=0;a0){

Whats the mistake?


And is it possible to dock the script-dialogue into the Interface over the ScriptUI Panels Folder?


Thanks a lot!

Ron


Return to posts index

Rainier Raydán
Re: setup composition height and width via expression
on Dec 14, 2017 at 8:55:54 pm

You can download the file here

https://drive.google.com/open?id=18nkpVfR8P5DDzVYLn_2SYKiWPIaPRDJX

just put this file in the C:\Program Files\Adobe\YOUR VERSION OF AE\Support Files\Scripts\ScriptUI Panels

then you can dock it


Return to posts index

Ron Grev
Re: setup composition height and width via expression
on Dec 15, 2017 at 7:46:50 am

Hy Rainier,

thanks a lot but i'm a little bit confused ☺ about the link.

GDrive shows me a cryptic file named:
changeCompWH_RR.jsxbin

☹ mybe a GDrive problem? try a zip?

Tanks, Ron


Return to posts index


Rainier Raydán
Re: setup composition height and width via expression
on Dec 15, 2017 at 2:01:02 pm

Just download the .jsxbin file.

Also you can download the zip file here:

https://drive.google.com/open?id=1unO24GcuYT_zIkwGADcyGUzQCVN3PGTL

Bye!


Return to posts index

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
© 2018 CreativeCOW.net All Rights Reserved
[TOP]