Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Forums Adobe After Effects Expressions PropertyValueType not working as expected

  • PropertyValueType not working as expected

  • Florian Zeiler

    February 17, 2020 at 8:23 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

  • Andrei Popa

    February 18, 2020 at 6:53 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.

  • Florian Zeiler

    February 18, 2020 at 7:30 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

  • Andrei Popa

    February 18, 2020 at 7:40 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.

  • Florian Zeiler

    February 18, 2020 at 11:35 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!

  • Andrei Popa

    February 18, 2020 at 1:08 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.

  • Florian Zeiler

    February 18, 2020 at 1:32 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!

Viewing 1 - 7 of 7 posts

Log in to reply.

We use anonymous cookies to give you the best experience we can.
Our Privacy policy | GDPR Policy