Skip to main content
Inspiring
April 20, 2021
Answered

app.project.reload() not working when changing "Type".

  • April 20, 2021
  • 1 reply
  • 1147 views

Hi everyone.

 

I have a problem working with mixed english and arab compositions and scripting.

In short, if I change the "Type" to "South Asian and Middle Eastern" with script and then reset paragraphs or try to create new layers, it's as if I did not change that setting. If I change it by hand, it works. However, I would like to be able to change it by script without restarting AE. This is the code I use.

 

app.preferences.savePrefAsString ('Type', 'Text Engine', '1');
app.preferences.saveToDisk ();
app.preferences.reload ();
resetParagraph(app.project.activeItem.selectedLayers[0])

function resetParagraph (myLayer) {
  var txtDoc = myLayer ('Text') ('Source Text').value;
  txtDoc.resetParagraphStyle ();
  myLayer ('Text') ('Source Text').setValue (txtDoc);
}

This just resets the paragraph to whatever setting "Type" had before running the script.

Thanks everyone in advance 😄

This topic has been closed for replies.
Correct answer Paul Tuersley

So I haven't been able to work out what Reset Paragraph should be doing for whatever you're trying to do. But I did look into flipping the Text Engine pref then trying to add some Arabic text to a newly created text layer. I figured that must be somewhat related to what you're trying to do.

 

And if this is what you're talking about then you're correct. Changing the pref through a script does not mean that newly created text layers are using the Middle Eastern engine and therefore still won't display Arabic text correctly. If you reopen the prefs it will show as changed but that change has no effect until relaunch. So yes this does appear to be a bug.

 

My previous tests in this area suggest that a text layer uses the Text Engine that was (manually) set in the prefs at the time they were created, and that there's no way to convert an existing text layer from one engine to another.

 

One less than ideal workaround in this area is to save a project containing a single comp with a text layer created using each text engine, then have the script import that project, use copyToComp to put the relevant text layer into your project, then recreate any settings from the text layers you're looking to replace. But not knowing what you're trying to do I've no idea if that's relevant.

 

You could file a bug report / feature request here:

https://adobe-video.uservoice.com/forums/911311-after-effects

 

1 reply

Inspiring
April 20, 2021

What part of the paragraph style are you saying 'works' when you reset manually (using Reset Paragraph in the Paragraph panel wing menu presumably) but not by script? Perhaps you could give some example steps to follow to understand what you're talking about. I've done some work in this area but have no clue what it is you're trying to achieve which makes it difficult to investigate.

Inspiring
April 20, 2021

The problem is in the changing of the setting, not in the reset paragraph. If I change the setting by hand, reset paragraph works fine. If I change the setting by script, I have to restart AE even if I run app.preferences.reload() (which I think should 'simulate' an AE restart) for the changes to take places.

 

If I open the preferences menu, it shows that the changes from the script have occured, but AE acts as if the Type setting is still the one from before runnning the script. 

Inspiring
April 20, 2021

So what should I be looking for that behaves differently?