Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Scripting applyPreset() Problem

Explorer ,
Dec 06, 2019 Dec 06, 2019

hey guys

When I applyPreset() through script code, add a priest to the text layer several times

 

 

 

var csInterface = new CSInterface();
csInterface.evalScript('test()');

 

 

 

 

 

function test() {
    var textLayer = app.project.activeItem.selectedLayers[0];

    var myMarker = new MarkerValue("In", "");
    textLayer.Marker.setValueAtTime(1, myMarker)
    textLayer.applyPreset(new File("C:\\Users\\I Do It\\AppData\\Roaming\\Adobe\\CEP\\extensions\\MyExtension\\In\\Fade Blur with Scale.ffx"));

    var myMarkers = new MarkerValue("Out", "");
    textLayer.Marker.setValueAtTime(2, myMarkers)
    textLayer.applyPreset(new File("C:\\Users\\I Do It\\AppData\\Roaming\\Adobe\\CEP\\extensions\\MyExtension\\Out\\Fade Blur with Scale.ffx"));
}

 

 

 

this Pic

Why Two Out FFX Created !!!

Whats my Problem ?????

20191206_202657.jpgexpand image

Tnx

TOPICS
Error or problem , Expressions , How to , Import and export , Resources , Scripting
2.0K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Contributor , Dec 06, 2019 Dec 06, 2019

I had to get a little bit fancy to solve this bizarre problem. Essentially what I added, is a variable that represents how many effects there should be. Every time you run this bit of code, you know there should be 2 additional effects applied. So I made a function to remove any of the extra effects! Let me know if you have any questions, but I tested this with your .ffx files and it works like a charm! (Don't forget to change the File locations)

 

var textLayer = app.project.activeItem.selectedLa
...
Translate
LEGEND ,
Dec 06, 2019 Dec 06, 2019

There is no problem. You are applying the preset twice, are you not? You seem to be under the mistaken impression that presets have an intrinsic temporal logic beyond the keyframes they were saved with, which isn't the case. You simply cannot apply the same preset twice and hope it will respond to your in- and out-point code. If you need such functionality, you have to create it inside the script to produce additional keyframes once the presets have been applied. You need to brush up on how presets actually work.

 

Mylenium

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Dec 06, 2019 Dec 06, 2019

Tnx for your reply

Me Added 2 preset in code but applying 3 preset  ! onec IN Twice Out !

And if Once Again Repeat This Code , We Have This Result !!!

whats the Problem ?

20191206_234137.jpgexpand image

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Dec 06, 2019 Dec 06, 2019

I think the first reply misunderstands the question and is being a bit passive aggressive. 

 

There are two possible problems I see that could be happening here. Either

1) One of the presets you are applying has 2 effects built into it

2) There is some code somewhere else in your extension that is causing this to happen

 

Your code suggests you are writing an extension, but your screenshot a script. Perhaps there is some more extension code that is causing this?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Dec 06, 2019 Dec 06, 2019

Tnx My Bro

Yes It is A Big Extension But We Have Problem Whit presetApply() Now And For Show This Problem Only Need To Run Up Code in Script Editor AE And Run !

 

Download My FFX From This Link

https://gofile.io/?c=0be9z6

 

Tnx For Attention

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Dec 06, 2019 Dec 06, 2019

Hmmm this is a really strange error. I tried applying multiple ffx of my own and can't get the same problem. It seems that when you only apply 1 of the IN or OUT presets, it only applies one instance of the effect. But if you apply two in any order, it will always apply a duplicate to the second. It's beyond me why it is doing this, but there are plenty of workarounds for it that will add minimal time to the processing speed of your extension.

 

After you've applied both presets, you can simply run this line of code to remove the duplicate effect.

textLayer.effect("Visual Text Animator_OUT 2").remove();
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Dec 06, 2019 Dec 06, 2019

Thanks for your expert response my Bro
However, there has to be a better solution
Due to the code you have submitted, our work in the image below becomes even harder whit very preset !

What do you think is the next solution?

 

20191206_234137.jpgexpand image

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Dec 06, 2019 Dec 06, 2019

I had to get a little bit fancy to solve this bizarre problem. Essentially what I added, is a variable that represents how many effects there should be. Every time you run this bit of code, you know there should be 2 additional effects applied. So I made a function to remove any of the extra effects! Let me know if you have any questions, but I tested this with your .ffx files and it works like a charm! (Don't forget to change the File locations)

 

var textLayer = app.project.activeItem.selectedLayers[0];
var requiredEffects = textLayer.Effects.numProperties+2;
// how many effects we know there should be

    var myMarker = new MarkerValue("In", "");
    textLayer.Marker.setValueAtTime(1, myMarker)
    textLayer.applyPreset(File("G:/Downloads/MyExtension/MyExtension/In/Fade Blur with Scale.ffx"));
    
    var myMarkers = new MarkerValue("Out", "");
    textLayer.Marker.setValueAtTime(2, myMarkers)
    textLayer.applyPreset(File("G:/Downloads/MyExtension/MyExtension/Out/Fade Blur with Scale.ffx"));
   removeExtraEffects(textLayer, requiredEffects);


function removeExtraEffects(layer, numEffects) {
        for(var i = layer.Effects.numProperties; i > numEffects; i--) {
            layer.effect(i).remove();
            }
    }

 

 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Dec 07, 2019 Dec 07, 2019

Tnx my bro for your little bit fancy 🙂

There must be a right solution to this strange problem
I thank you for the trick you have solved

Tnx A lot

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Mar 09, 2020 Mar 09, 2020

the applyPreset() seems to apply ( number of selected layers ) of time. 

you need to unselect all layers , and reselect the layer that you want to apply the preset to before the applyPreset() line. 

 

 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Mar 09, 2020 Mar 09, 2020
LATEST
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines