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

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

Explorer ,
Apr 20, 2021 Apr 20, 2021

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 😄

TOPICS
Scripting
1.1K
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

Enthusiast , Apr 21, 2021 Apr 21, 2021

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 disp

...
Translate
Enthusiast ,
Apr 20, 2021 Apr 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.

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 ,
Apr 20, 2021 Apr 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. 

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
Enthusiast ,
Apr 20, 2021 Apr 20, 2021

So what should I be looking for that behaves differently?

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
Enthusiast ,
Apr 21, 2021 Apr 21, 2021

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

 

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 ,
Apr 21, 2021 Apr 21, 2021

Thank you for your time and expertise Paul.

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 ,
Apr 21, 2021 Apr 21, 2021

One more question. Is it possible, from what you know, to check in which engine was the text created?

 

PS. You can convert an existing layer to another engine by reseting paragraph(works both manually and by script and converts the layer to the current engine)

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
Enthusiast ,
Apr 21, 2021 Apr 21, 2021

I'm not aware of any flag you can read which would tell you the engine used. It might have to be some hack like comparing the layer width using .sourceRectAtTime(). Properly joined Arabic for example would likely be narrower than the incorrect spacing using the Latin engine.

 

So just speculating here but.....you have this 'asset' project containing text layers for each of the text engines which you import. You make a copy of the layer you want to check and replace the text with something Arabic using a certain font and size. You apply the same text, font and size to the two imported text layers then compare the width of each to work out which engine the original is using.

 

That's good to know about using Reset Paragraph to switch the engine to the currently set one. I thought that might be what you were referring to and thought I'd tried it, but maybe I tried it when the pref had been falsely set by the scripting method. Just tried again and I see it does work so thanks for that info. That would be really useful if the scripted pref change worked properly!

 

Is there even any drawback to just always using the Middle Eastern engine regardless of whether you're just using Latin text?

 

 

 

 

 

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 ,
Apr 23, 2021 Apr 23, 2021
LATEST

Regarding your last question, I haven't find any difference yet but I do not want to risk it. 

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