ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

PropertyValueType not working as expected

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Florian Zeiler
PropertyValueType not working as expected
on Feb 17, 2020 at 8:23:28 pm

Dear expressionists!

I am currently working on a little script to help with effect controls and i need to check the property's "PropertyValueType" using .PropertyValueType as suggested in the Scripting Guide.

However, the results seem somewhat unexpected to me:

When checking the "Scale" (transform.scale) property of a regular solid layer, i was expecting to either get "PropertyValueType.TwoD_SPATIAL" or "PropertyValueType.TwoD" - but comparing myPropery.propertyValueType against these two doesnt work - for some reason it only works with "PropertyValueType.ThreeD" which doesn't make any sense to me, as it is a 2-dimensional value.

My simplified code does the following:


var myComp = app.project.activeItem;
var numLayer = myComp.selectedLayers;
var ind = numLayer[0].index;
var myLayer = myComp.layer(ind);

for (i = 0; i < myLayer.selectedProperties.length; i++) {
var prop = myLayer.selectedProperties[i];

if (prop.propertyValueType == PropertyValueType.OneD) {
myLayer.effect.addProperty("ADBE Slider Control").name = prop.name;
} else if (prop.propertyValueType == PropertyValueType.TwoD || prop.propertyValueType == PropertyValueType.TwoD_SPATIAL) {
myLayer.effect.addProperty("ADBE Point Control").name = prop.name;
}


The "OneD" works perfectly for e.g. Opacity.. but Scale and/or Position don't work with TwoD and TwoD_SPATIAL at all.

Any ideas? What am i doing wrong?

Thanks in advance

Kind regards


Return to posts index

Andrei Popa
Re: PropertyValueType not working as expected
on Feb 18, 2020 at 6:53:51 am

Scale and position are 3d properties. It is only in the After Effects interface that the last is hidden if the layer is not 3d enabled. If you check the scale of a layer by script, you will get [100,100,100].

So, in short, you are doing nothing wrong and the answer of .PropertyValueType is correct. They are just 3d properties, not 2d.

Andrei
My Envato portfolio.


Return to posts index

Florian Zeiler
Re: PropertyValueType not working as expected
on Feb 18, 2020 at 7:30:17 am

Thanks for your quick reply, Andrei.

That makes absolute sense, thank you for the clarification. So in my code, i should probably check if the selected property's layer is a 3D layer as well?

After i create the point-control for the scale of a 2D-Layer, i still only connect the values to the first two values of the scale array, correct? By that, i mean [value[0],value[1]] for the 2D Layer. And if the layer has the 3D-switch turned on, i connect three values to the scale? ( [value[0],value[1],value[2]]

Thanks in advance

Kind regards

Florian


Return to posts index


Andrei Popa
Re: PropertyValueType not working as expected
on Feb 18, 2020 at 7:40:07 am

You can directly set the scale and position to a 2D vector.

This code works:

var a = app.project.item(1).layer("Shape Layer 1")("Transform")("Scale");
var b = app.project.item(1).layer("Shape Layer 1")("Effects")("Point Control")("Point").value;
a.setValue(b);


It works with scale and position of a layer. Doesn't matter if the 3d it's turned on or not. The last element of the value is set to zero for position and 100 for scale(the default values).

Andrei
My Envato portfolio.


Return to posts index

Florian Zeiler
Re: PropertyValueType not working as expected
on Feb 18, 2020 at 11:35:32 am

That's great to know - i need to create layer controls that grab the original value (at the time of script execution) from the selected property, so your code snippet is very helpful as well. Thanks a lot ☺

By the way - if all of these properties like Scale and Position are already 3-dimensional values by default - for which properties do we actually need the .TwoD and .TwoD_SPATIAL enumerations?

Thanks again, Andrei!


Return to posts index

Andrei Popa
Re: PropertyValueType not working as expected
on Feb 18, 2020 at 1:08:40 pm

I never thought about that. Maybe a point control? Or maybe some values that can't expand to 3d. Surely there must be some in all the effects.

Andrei
My Envato portfolio.


Return to posts index


Florian Zeiler
Re: PropertyValueType not working as expected
on Feb 18, 2020 at 1:32:16 pm

Yes, it seems to be for the 2-dimensional point control for example - i just tried to pass the value from "Scale" to a point control and it actually just takes a 2-value array, so that is that.

Thanks for your kind help, Andrei - much appreciated!


Return to posts index

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