FORUMS: list search recent posts

Adding a [x, y, z] value to an [x, y] value

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Jay Brown
Adding a [x, y, z] value to an [x, y] value
on May 27, 2016 at 9:14:42 pm

Is there an easy way to add an [x, y, z] value to an [x, y] value?

You get the error "result must be of dimension 2, not 3". Is there a way to check the length of the property so that only the [x] and [y]s are added together and the [z] is ignored?

I can't seem to figure out an easy way to do this.

Thanks,
-Jay


Return to posts index

Dan Ebberts
Re: Adding a [x, y, z] value to an [x, y] value
on May 27, 2016 at 9:55:56 pm

Something like this:

a = [100,100];
b = [100,100,100];
a + [b[0],b[1]]


Dan



Return to posts index

Jay Brown
Re: Adding a [x, y, z] value to an [x, y] value
on May 27, 2016 at 10:33:51 pm

Thanks for the response Dan!

Sorry I should have fully explained what I'm trying to do. I have a 3D Point controller on a Null and I'm trying to create an expression that works universally for whatever property I add it too. For example the 3D Point values are [25, 50, 100].
If I add it to rotation the value would be [25]. If I add to the scale it the value would be [25, 50]. If I add it too a 3D point the value would be [25, 50, 100] and so on.


This is what I started with:

oSet = thisComp.layer("Controller").effect("Offset")("3D Point");
value + oSet;


Is there a way to tell the property to ignore the extra value?


Return to posts index



Dan Ebberts
Re: Adding a [x, y, z] value to an [x, y] value
on May 27, 2016 at 10:55:07 pm

I think this works:


oSet = thisComp.layer("Controller").effect("Offset")("3D Point");
if (value instanceof Array){
if (value.length == 2){
value + [oSet[0],oSet[1]];
}else{
value + oSet;
}
}else{
value + oSet[0];
}



Dan



Return to posts index

Jay Brown
Re: Adding a [x, y, z] value to an [x, y] value
on May 27, 2016 at 11:02:36 pm

It works like a charm! You are an absolute legend!

Originally I tried .length and length() on oSet and kept getting errors, I didn't even think about trying it on the value itself. I finally get now too how the (value instanceof Array) works!

thank you so much,
-Jay


Return to posts index

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