Alex Printz
Forum Replies Created
-
Thanks Dan!
Between the two examples I think I understand I needed to assemble the whole line of code before the evaluation; I couldn’t use eval to build myself a string of properties to call later. Neat.
-
for reference, I was trying to build a simple expression that could be placed into any property and reference a guide layer of itself inside another comp via pulldown.
referenceProperty = pathToThis();
targetLayer = effect("Reference Layer")(1);
thisName = thisLayer.name;
targetInsideComp = comp(targetLayer.name).layer(thisName);
targetInsideComp[referenceProperty]valueAtTime(time-targetLayer.inPoint);;function pathToThis(){
str = '("' + thisProperty.name + '")';
i = 1;
while(thisProperty.propertyGroup(i).name != thisLayer.name){
str = '("' + thisProperty.propertyGroup(i).name + '")' + str;
i++;
}
return eval(str)
} -
Dan, I am trying to use a light version of this, but after the string is evaluated the values are getting capitalized, making AE return undefined errors.
If I put this into an opacity property of a layer, it should be evaluating as “transform.opacity”, and hence referencing itself.
str = '("' + thisProperty.name + '")';
i = 1;
while(thisProperty.propertyGroup(i).name != thisLayer.name){
str = '("' + thisProperty.propertyGroup(i).name + '")' + str;
i++;
}
eval(str)
However, I am getting “Error at line 1 in property ‘Opacity’ of layer…. Function “Transform” is undefined., an expression was disabled…Any idea how to fix this? I’m not too privy to eval function, and what I read there aren’t simple controls, and it looks like a lot of web developers avoid it for problems like this.
I’ve tried a simple string parse, but that doesn’t help.
function jsUcfirst(string) return string.charAt(0).toUpperCase() + string.slice(1);
If it parse’s before the eval the string change is ignored and still evaluated as capitals, and if it’s after then it’s returned to a string and not being executed. Any ideas anyone? -
Alex Printz
June 8, 2018 at 6:50 pm in reply to: Producing randomly sized squares that must correspond to an underlying grid?Yeah your best bet is a single precomp, with a square box falling into the center then out of the center point and not going outside the X-boundaries of the comp. Make sure they’re square an a simple size (e.g., 100×100, in a comp 100×2000)
Then work on making a generator inside a master comp. make a grid generator that counts repeats/offsets inside of a shape layer based on property group indexes and numProperties, and then make duplicates of the precomped square layer base their position and scale off of those grid repeats from their own name (e.g, square-A_2). Split the layer name by the -, and then the _ to access the row and column data to represent X/Y values and times.
Then all you need to do is make a master controller with in/out sliders for times, and in/out rates. Make each layer have a random seed that is within those in/out times. Add some generator>fills or hue/saturations to each of them that are referencing the master controller. I’m not entirely sure offhand how to make sure that the grids fall in their rows in order so that they don’t intersect each other in the Y-axis, but I would think that could be built into the layer names.
Good luck, going to be quite a bit of scripting and sounds like a fun project!
-Alex
-
Alex Printz
June 6, 2018 at 4:41 pm in reply to: Adding a checkbox if inside an already big if else loop.Ok, If I’m understanding correctly, you are time-remapping asset layers in your subcomp “Character Parts” to choose the shape, and you have separate asset layers to hold the fat and regular shapes.
Something like this should work in the opacity code for the fat asset opacity:
try{
characterN=comp("Master Panel").layer("Select Character").text.sourceText;
if (characterN > 0 ){
charString = characterN.toString();
while ( charString.length < 3) charString = "0" + charString;
charString = "Character " + charString;
comp("Master Panel").layer(charString).effect("Add Weight")("Checkbox") == 1 ? 100 : 0;
}else 0;
}catch(err){50};and something like this in the regular asset opacity:
try{
characterN=comp("Master Panel").layer("Select Character").text.sourceText;
if (characterN > 0 ){
charString = characterN.toString();
while ( charString.length < 3) charString = "0" + charString;
charString = "Character " + charString;
comp("Master Panel").layer(charString).effect("Add Weight")("Checkbox") == 1 ? 0 : 100;
}else 0;
}catch(err){50};note that the only difference is the final line inside the If statement is that if the checkbox is checked, the outputs for the layers swaps 100/0 to 0/100.
-
Alex Printz
June 5, 2018 at 8:46 pm in reply to: Adding a checkbox if inside an already big if else loop.It’s hard to tell what would serve you best from your description.
How are your 2nd set of bodies stacked up (the heavier ones)? If you are going to have a 2nd set of frames with larger bodies for all of the characters and you simply time-remap for various assets, simply offset their values by a number larger than your total assets (in this case I have added 500, change that number for as many as you would need).
so in my example, if they are regular, character 145 would have a body frame 145, but if they were fat, they would be 645, etc.
HOWEVER,
If you were referencing specific layers, do a label check instead, and call the 2nd set “heavy_character”, then just have a 2nd set of body layers, rather than time remapping, to draw from.Simply un-comment one of the test examples and see what you’d prefer. When you decide one, add another check for the color as well.
-Alex
=====================
try{
offsetWeight = 500; //offsets the time reference layer;
label = "character ";characterN=comp("Master Panel").layer("Select Character").text.sourceText;
AddWeight = comp("Master Panel").layer("charString").effect("Add Weight")("Checkbox");if (characterN > 0 ){
charString = characterN.toString();
while ( charString.length < 3) charString = "0" + charString;//THIS ONE CHANGES THE CHARACTER FRAME REFERENCE
//if (AddWeight == 1) charString = parseInt(charString) + offsetWeight;//THIS ONE CHANGES THE CHARACTER LABEL USED IN LAYER REFERENCING
//if (AddWeight == 1) label = "heavy_character ";charString = label + charString;
state=comp("Master Panel").layer(charString).effect("Outfit")("ADBE Slider Control-0001");
framesToTime(state);
}else{res};
}catch(err){res}; -
Try this:
var pathLayer = thisComp.layer(“Shape Layer 1”);
pathLayer.points(time)[1]you might need to do a comp/world conversion conversion.
-Alex