Copy link to clipboard
Copied
I would like to add basic opacity text animator to text layer through scripting and change its attributes.
I am looking for access mainly for:
Start
End
Offset
Units
Based on
Mode
Opacity
What I got so far. I am able to create animator with text selector:
var animator = newLayer.Text.Animators.addProperty("ADBE Text Animator");
animator.name = "Line Selector";
var opacityAnimator = animator.property("ADBE Text Animator Properties").addProperty("ADBE Text Opacity");
var selector = animator.property("ADBE Text Selectors").addProperty("ADBE Text Selector");
I can access and change most of the settings like this:
selector.property("Offset").setValue(1);
selector.property("Advanced").property("Mode").setValue(2);
However as soon as I change the units to Index from percentage like this:
selector.property("Advanced").property("Units").setValue(2);
I lose all control over selector. I can no longer change anything.
If I again use something like:
selector.property("Start").setValue(100);
or
selector.property("ADBE Text Index Start").setValue(100);
it does nothing.
Also i was not able to find a way to change the Opacity of the animator whatsoever. Even before the "units" change. Not sure what is the correct syntax there.
Thanks for your help,
Martin
I have finally found what was I looking for. propertyIndex actually gets you the index of a animator.
So this is the way how to get Index of just created animator on a layer if it helps someone else:
var animator = Layer.Text.Animators.addProperty("ADBE Text Animator");
var m = animator.propertyIndex;
Copy link to clipboard
Copied
Adress the properties by their relative property indices instead of the UI name. Your script simply locks up because the property names are no longer valid after your changes. If you wanted to stick with using the named properties, your code would have to have provision to check for those things and adapt accordingly, i.e. you would need to branch with conditionals.
Mylenium
Copy link to clipboard
Copied
Hi Mylenium,
Thank you for your answer. When working with indices I can access everything now.
I was able to access everything like this:
newLayer.text.animator(m).selector(1).property("Advanced").property("Based On").setValue(4);
However I have still struggled with Start/End and Opacity. I though these should work, but neither did.
newLayer.text.animator(m).selector(1).property("End").setValue(4);
newLayer.text.animator(m).selector(1).property("ADBE Text Index End").setValue(4);
I was able to find different syntax which finally worked, if someone will have the same trouble:
//Start to 0
newLayer.property("ADBE Text Properties").property("ADBE Text Animators").property(m).property("ADBE Text Selectors").property(1).property("ADBE Text Index Start").setValue(0);
//End to 1
newLayer.property("ADBE Text Properties").property("ADBE Text Animators").property(m).property("ADBE Text Selectors").property(1).property("ADBE Text Index End").setValue(1);
//Opacity to 0
newLayer.property("ADBE Text Properties").property("ADBE Text Animators").property(m).property("ADBE Text Animator Properties").property("ADBE Text Opacity").setValue(0);
Now I have one hopefully final question. Now I am addressing the animator with index "m", because I know I have only one animator on layer. But in the case there will be multiple. How can I check for the index of a animator i have just created with var animator = newLayer.Text.Animators.addProperty("ADBE Text Animator"); ?
Thank you,
Martin
Copy link to clipboard
Copied
Animators enumerate like any other property and can be checked this way. If you didn't do anything and are just relying on defaults, your newly added animators will always be the last entry added after existing props. Otherwise you may just need to add additional checks for the type and the order of the animators. It may also help if you simply add naming functions to your script and check for that, so not always the default automatic names are used.
Mylenium
Copy link to clipboard
Copied
Thanks again for your answer.
I am adding just one animator, but the script should work on selected layer which may already have and animator. I am also renaming the animator i have created but I want to give it a descriptive name and avoid the off-chance the other animator having the same name. I have read somewhere in other topic that AE would choose the first animator in order which would match the name, which in this case would be not the correct one. I thought of giving it some weird name and after my changes give it back proper name, but after I change the units i lose control of it and cannot change the name again.
And I am having trouble finding how to check for animators already present in a layer. I cant find any mention of it in ae scripting guide nor other topics in these forums. For layers i can get layer.index but animator.index is undefined. For keyframes and layers in composition are numKeys and numItems, but no luck with numAnimators.
Basicly i am looking for getNumberAnimators() function name if such function or property exists and if not, for a way to program such a function.
Thank you
Copy link to clipboard
Copied
I have finally found what was I looking for. propertyIndex actually gets you the index of a animator.
So this is the way how to get Index of just created animator on a layer if it helps someone else:
var animator = Layer.Text.Animators.addProperty("ADBE Text Animator");
var m = animator.propertyIndex;
Copy link to clipboard
Copied
Martin- I'm impressed with your script. I am also trying to write a script that creates a text animator with the positino property on the selected text layer. Can you help me? I keep getting an error
Copy link to clipboard
Copied
Probably something like this:
var myLayer = app.project.activeItem.layer(1);
var myAnimator = myLayer.property("ADBE Text Properties").property("ADBE Text Animators").addProperty("ADBE Text Animator");
var mySelector = myAnimator.property("ADBE Text Selectors").addProperty("ADBE Text Selector");
var myProp = myAnimator.property("ADBE Text Animator Properties").addProperty("ADBE Text Position 3D");
Copy link to clipboard
Copied
This worked! Thanks, Dan.