Highlighted

[Script] Remove hidden properties ??

New Here ,
Nov 12, 2020

Copy link to clipboard

Copied

So I want to write a script that removes the properties that are hidden (that have the eyeball icon disabled).

I started with this script:

var layersProperties = app.project.activeItem.selectedProperties;

for (i = 0; i < layersProperties.length; i++){
    if(layersProperties[i].enabled == false){
        layersProperties[i].remove();
    }
}

 

It works when selecting normal properties, but there's two problems:

1) The script doesn't work when selecting a PropertyGroup with another property, it deletes the first hidden PropertyGroup then gives an error message.

2) I need to manually select the properties, what can I do to make the script work by simply selecting the layers.

 

Thank you so much!

TOPICS
Scripting

Views

30

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more

[Script] Remove hidden properties ??

New Here ,
Nov 12, 2020

Copy link to clipboard

Copied

So I want to write a script that removes the properties that are hidden (that have the eyeball icon disabled).

I started with this script:

var layersProperties = app.project.activeItem.selectedProperties;

for (i = 0; i < layersProperties.length; i++){
    if(layersProperties[i].enabled == false){
        layersProperties[i].remove();
    }
}

 

It works when selecting normal properties, but there's two problems:

1) The script doesn't work when selecting a PropertyGroup with another property, it deletes the first hidden PropertyGroup then gives an error message.

2) I need to manually select the properties, what can I do to make the script work by simply selecting the layers.

 

Thank you so much!

TOPICS
Scripting

Views

31

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Nov 12, 2020 0
Mylenium LATEST
Most Valuable Participant ,
Nov 12, 2020

Copy link to clipboard

Copied

Well, of course you'd have to add a sub-loop for complex property groups and check their property types. Conversely you'll have to add the pertinent code that checks the selection state of layers. AE doesn't check the contexts when launching a script. It just executes it blindly and you have to add your own safeguards.

 

Mylenium

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Nov 12, 2020 0