Frustrating Expressions error

Moderators: Disciple, zlovatt

Post Reply
mtals4
Posts: 5
Joined: July 10th, 2008, 8:38 am
Location: Los Angeles
Contact:

Hey everyone first time posting here, but have been reading a lot of the other posts. Great information!

I cobbled/hacked together the following code from a tutorial I found on Dan's site about random motion.

The idea with this expression was to have a couple of 3D layers randomly float in the x and y axis, while allowing the Z axis to remain constant where I set it.

segMin & segMax control the length of time before change in vector.
minVal & maxVal control the range of motion.

I am using five floating layers and a controller null with sliders. The floating layers are children of the null controller.

When I RAM preview, scrub the playhead all the layers work great. Except when I place the comp in the render queue and start the render process I get the following error. And the floating layers don't float.

'After Effects warning: logged 9 errors, please check log. First error was 'warnings: Class 'Layer' has no property or method named 'start' Expression disabled.
Error occurred at line 23.
Comp: 'Blue Bars white bckgrnd'
Layer: 11 ('panel 36')
Property: 'Position'

Here is the code in the position property.
segMin = thisComp.layer("Panel Controller-1").effect("Seg Min Control")("Slider") //minimum segment duration
segMax = thisComp.layer("Panel Controller-1").effect("Seg Max Control")("Slider"); //maximum segment duration
minVal = thisComp.layer("Panel Controller-1").effect("Min Value Modifier")("Slider");
maxVal = thisComp.layer("Panel Controller-1").effect("Max Value Modifier")("Slider");

end = 0;
j = 0;
while ( time >= end){
j += 1;
seedRandom(j,true);
start = end;
end += random(segMin,segMax);
}
endVal = random(minVal,maxVal);
seedRandom(j-1,true);
dummy=random(); //this is a throw-away value
startVal = random(minVal,maxVal);

x = position[0];
y = position[1];
z = position[2];

linear(time,start,end,[x,startVal,z],[x,endVal,z])

I thank you in advance for any guidance on this issue.
Matthew

mixturefilms.com
User avatar
lloydalvarez
Enhancement master
Posts: 460
Joined: June 17th, 2004, 9:27 am
Location: New York City, NY
Contact:

Hard to say based on the info you provided why that expression is not working, but if you just want the layer to move randomly in x,y here's a much simpler way to do that:

Code: Select all

floatSpeed = 15;  //speed in fps of the float movement
a= 50; // amount to float

w=wiggle(floatSpeed,a);
[w[0],w[1],value[2]]
-Lloyd
mtals4
Posts: 5
Joined: July 10th, 2008, 8:38 am
Location: Los Angeles
Contact:

lloyd, thanks for the help.

The code you provided worked great. The only issue I have is the movement generated is more of an 'easy ease' movement. The original code made the movement more linear, that is what I was trying for ... But sometimes time or lack it ruins everything.
Matthew

mixturefilms.com
Dan Ebberts
Posts: 320
Joined: June 26th, 2004, 10:01 am
Location: Folsom, CA
Contact:

Matthew,

Sorry - I missed this earlier. Something like this should work:

Code: Select all

segMin = .5; //thisComp.layer("Panel Controller-1").effect("Seg Min Control")("Slider") //minimum segment duration
segMax = 1.0; //thisComp.layer("Panel Controller-1").effect("Seg Max Control")("Slider"); //maximum segment duration
minVal = -400; //thisComp.layer("Panel Controller-1").effect("Min Value Modifier")("Slider");
maxVal = 400; //thisComp.layer("Panel Controller-1").effect("Max Value Modifier")("Slider");

end = 0;
j = 0;
while ( time >= end){
j += 1;
seedRandom(j,true);
strt = end;
end += random(segMin,segMax);
}
endVal = random([minVal,minVal],[maxVal,maxVal]);
seedRandom(j-1,true);
dummy=random(); //this is a throw-away value
startVal = random([minVal,minVal],[maxVal,maxVal]);

xy = linear(time,strt,end,startVal,endVal)
value + [xy[0],xy[1],0]

Note that I substitued values for your sliders to test, but you should be able to switch back.

Dan
mtals4
Posts: 5
Joined: July 10th, 2008, 8:38 am
Location: Los Angeles
Contact:

Works beautifully! Dan you are the man!

Thank you so much! I still have a lot to learn about expressions....
Matthew

mixturefilms.com
mtals4
Posts: 5
Joined: July 10th, 2008, 8:38 am
Location: Los Angeles
Contact:

Dan,

I spoke a little too soon, I still think you are the man...

But, I cannot get this to work when I start a render in the queue. Even before I attach my sliders...

I posted a project that won't render, it contains the layer arrangement I am working with.
Again it all works during a RAM preview just not during a "real render".

The project can be downloaded here.
http://mixturefilms.com/clients/aehelp/.

Thank you in advance for any help you can provide.
Matthew

mixturefilms.com
Dan Ebberts
Posts: 320
Joined: June 26th, 2004, 10:01 am
Location: Folsom, CA
Contact:

Hmm... that's strange. It looks like the expression is evaluating at a time before zero for some reason, which would leave the strt variable undefined. Try this slight variation:

Code: Select all

segMin = .5; //thisComp.layer("Panel Controller-1").effect("Seg Min Control")("Slider") //minimum segment duration
segMax = 1.0; //thisComp.layer("Panel Controller-1").effect("Seg Max Control")("Slider"); //maximum segment duration
minVal = -400; //thisComp.layer("Panel Controller-1").effect("Min Value Modifier")("Slider");
maxVal = 400; //thisComp.layer("Panel Controller-1").effect("Max Value Modifier")("Slider");

end = 0;
strt = 0;
j = 0;
while ( time >= end){
  j += 1;
  seedRandom(j,true);
  strt = end;
  end += random(segMin,segMax);
}
endVal = random([minVal,minVal],[maxVal,maxVal]);
seedRandom(j-1,true);
dummy=random(); //this is a throw-away value
startVal = random([minVal,minVal],[maxVal,maxVal]);

xy = linear(time,strt,end,startVal,endVal)
value + [xy[0],xy[1],0]

Dan
Paul Tuersley
Posts: 704
Joined: June 5th, 2004, 7:59 am
Location: London, UK

Dan Ebberts wrote:Hmm... that's strange. It looks like the expression is evaluating at a time before zero for some reason, which would leave the strt variable undefined.
I believe the error is caused by motion blur. AE CS3 has a new default shutter angle of -90, so motion blur is centred around a keyframe rather than only blurring forwards in time. So to calculate motion blur on the first frame, it needs to evaluate the expression at a time before zero.

Paul
Dan Ebberts
Posts: 320
Joined: June 26th, 2004, 10:01 am
Location: Folsom, CA
Contact:

Ah, that makes perfect sense. Thanks Paul.

Dan
mtals4
Posts: 5
Joined: July 10th, 2008, 8:38 am
Location: Los Angeles
Contact:

Dan

Thank you for posting the update. Works great even when rendering.

Thank you everyone for their contribution.
Matthew

mixturefilms.com
Post Reply