Bryan Woods
Forum Replies Created
-
Interesting. So that does work, but I want to know why. Is it an order of operations thing between if/else and try{catch}, where try is processed before a typical if/else loop would?
Thanks for the help Dan. Glad to see a familiar face still here.
-
Ok, actually, I need a little more help. I need to be able to apply this expression to each layer thats already in a good position. The wiggle just needs to pick up from where the layer is, and I’m not getting that to work. I think this comes down to how I’m adding everything up on the last line.
Essentially, I like the value generated from position.value+random(a,b). Now I want to initiate the wiggle from that value.
-
Oh, wait! I think I got it. Re-reading Dan’s write-up on looping wiggle expressions, looks like I was forgetting the default values for the third and fourth spots in the wiggle() expression (1, 0.5). Adding these in make my code work! I’ve included the code below for anyone else who may want to use a randomly positioning layer in 3D space with random looping wiggle position
seedRandom(index,true);
s = thisComp.layer("Seed").effect("Seed")("Slider");xMod = thisComp.layer("Seed").effect("X_Mod")("Slider");
yMod = thisComp.layer("Seed").effect("Y_Mod")("Slider");
zMod = thisComp.layer("Seed").effect("Z_Mod")("Slider");a = [-s*xMod, -s*yMod, -s*zMod];
b = [s, s, s];wigFreq = thisComp.layer("Seed").effect("WigFreq")("Slider");
wigAmp = thisComp.layer("Seed").effect("WigAmp")("Slider");
loopTime = 2;
t = time % loopTime;wiggleX1 = wiggle(wigFreq, wigAmp, 1, 0.5, t);
wiggleX2 = wiggle(wigFreq, wigAmp, 1, 0.5, t - loopTime);
wiggleY1 = wiggle(wigFreq, wigAmp, 1, 0.5, t);
wiggleY2 = wiggle(wigFreq, wigAmp, 1, 0.5, t - loopTime);
wiggleZ1 = wiggle(wigFreq, wigAmp, 1, 0.5, t);
wiggleZ2 = wiggle(wigFreq, wigAmp, 1, 0.5, t - loopTime);
X=linear(t, 0, loopTime, wiggleX1, wiggleX2)[0];
Y=linear(t, 0, loopTime, wiggleY1, wiggleY2)[1];
Z=linear(t, 0, loopTime, wiggleZ1, wiggleZ2)[2];position.value + random(a,b)+[X,Y,Z];
-
Ah, super helpful. Thanks Dan.
For anyone interested, here is my script. It will take all selected comps, and scale them by the factor you set, and re-center the layers in them. Simple, but strangely I couldn’t find anyone else who made something like this that worked for more than one selected comp.
Copy and paste the below into a new text document, with a .jsx extension and throw into your AE scripts folder:
//prompt percentage and set selections
var percent = prompt("Resize factor (percentage):","200");
var mySelection = app.project.selection;
app.beginUndoGroup("scaleSelectedComps.jsx");//for every comp selected, set resolution based on percent value from user
for (var i = 0; i < mySelection.length; i++){
if (mySelection[i] instanceof CompItem){
mySelection[i].width = Math.round(mySelection[i].width * percent/100);
mySelection[i].height = Math.round(mySelection[i].height* percent/100);
curComp = mySelection[i];//for each layer within each selected comp, scale and re-center based on percent value from user
for (var b = 1; b <= curComp.numLayers; b++){
var curLayer = curComp.layer(b);
curLayer.scale.setValue([percent,percent]);
curLayer.position.setValue([curComp.width/2,curComp.height/2]);
}
}
}
app.endUndoGroup();
//done! :) -
Ok, I’ve gone in and rewritten it a little bit, but I’m getting an error at line 12: “Undefined is not an object”. Not sure if I’m missing the correct syntax for scaling or what.
var percent = prompt("Resize factor (percentage):","50");
var mySelection = app.project.selection;
app.beginUndoGroup("scaleSelectedComps.jsx");
for (var i = 0; i < mySelection.length; i++){
if (mySelection[i] instanceof CompItem){mySelection[i].width = Math.round(mySelection[i].width * percent/100);
mySelection[i].height = Math.round(mySelection[i].height* percent/100);
curComp = mySelection[i];
for (var b = 0; b <= curComp.numLayers; b++){
var curLayer = curComp.layer[b];
curLayer.scale.setValue([percent,percent]); //this is where the error is
}
}
}
app.endUndoGroup(); -
Ah, you’re right. I didn’t take a very close look at it from the AEenhancer’s forum.
-
Ah, I should have been more specific then. Rectangle is a shape layer with its anchor positioned to middle left. The object is also another shape layer.
-
Hmm, not quite. As I pull object out, rectangle scales, but at a slower rate than object. Ideally the scale of rectangle should be that the edge of rectangle looks like its attached to object as its pulled out.
-
Hi Fabio. I’ve scrapped my project unfortunately. However, the good news is someone has made a plugin for working with 360 video in AE! Check it out here:
https://forums.creativecow.net/thread/2/1064966 -
I guess I’m just not following what you mean by the URI. If I used this code:
var textFolder = Folder.selectDialog();
var textName = "filename.txt";
var textFilePath = textFolder.path + "/" + textFolder.name + "/" + escape(textName);You mean to tell me that those “/” that you have in there manually will be put in correctly based on the OS? So if I’m on a PC and run this script, i’d get “\” instead?