Activity › Forums › Adobe After Effects Expressions › setup composition height and width via expression
-
setup composition height and width via expression
Posted by Ron Grev on December 13, 2017 at 8:14 amHello 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
Rainier Raydán replied 8 years, 5 months ago 3 Members · 6 Replies -
6 Replies
-
Dan Ebberts
December 13, 2017 at 4:44 pmNo, expressions can only control the value of the property hosting the expression.
Dan
-
Rainier Raydán
December 13, 2017 at 6:54 pmHi 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!
-
Ron Grev
December 14, 2017 at 8:36 pmHello 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
-
Rainier Raydán
December 14, 2017 at 8:55 pmYou 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
-
Ron Grev
December 15, 2017 at 7:46 amHy 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
-
Rainier Raydán
December 15, 2017 at 2:01 pmJust download the .jsxbin file.
Also you can download the zip file here:
https://drive.google.com/open?id=1unO24GcuYT_zIkwGADcyGUzQCVN3PGTL
Bye!
Reply to this Discussion! Login or Sign Up