Skip to main content
stib
Inspiring
October 12, 2022

getPrefAsBool seems to hooked up to computerSaysNo.exe

  • October 12, 2022
  • 1 reply
  • 243 views

The extendscript function

 

 

app.preferences.getPrefAsBool()

 

 

always returns false. Here's a demo, comparing it to getPrefAsLong, which seems to work:

 

 

app.preferences.getPrefAsLong("Main Pref Section v2", "Pref_SEQUENCE_ZEROS", PREFType.PREF_Type_MACHINE_SPECIFIC)
> 5
// returns 5 which should be truthy, but
app.preferences.getPrefAsBool("Main Pref Section v2", "Pref_SEQUENCE_ZEROS", PREFType.PREF_Type_MACHINE_SPECIFIC)
> false
//returns wrong answer

app.preferences.getPrefAsLong("Main Pref Section v2", "Pref_HIDE_LOCKED_MASKS", PREFType.PREF_Type_MACHINE_SPECIFIC)
> 0
// returns 0, should be falsy
app.preferences.getPrefAsBool("Main Pref Section v2", "Pref_HIDE_LOCKED_MASKS", PREFType.PREF_Type_MACHINE_SPECIFIC)
> false
//returns false, so it's not just inverting the answer

app.preferences.getPrefAsLong("Main Pref Section", "Pref_SCRIPTING_FILE_NETWORK_SECURITY")
> 1
//returns 1. Note, using "Main Pref Section" and no PREFTYPE enum
app.preferences.getPrefAsBool("Main Pref Section", "Pref_SCRIPTING_FILE_NETWORK_SECURITY")
> After Effects error: The section name and key (Main Pref Section, Pref_SCRIPTING_FILE_NETWORK_SECURITY) could not be found in the preferences.
// throws an error
app.preferences.getPrefAsBool("Main Pref Section", "Pref_SCRIPTING_FILE_NETWORK_SECURITY", PREFType.PREF_Type_MACHINE_SPECIFIC)
> After Effects error: The section name and key (Main Pref Section, Pref_SCRIPTING_FILE_NETWORK_SECURITY) could not be found in the preferences.
// tried with the preftype specified, still not found
app.preferences.getPrefAsBool("Main Pref Section v2", "Pref_SCRIPTING_FILE_NETWORK_SECURITY", PREFType.PREF_Type_MACHINE_SPECIFIC)
> false
// returns false, so it found the pref, but reported it wrong.

 

This topic has been closed for replies.

1 reply

JohnColombo17100380
Community Manager
Community Manager
February 24, 2023

Hi @stib,

Thank you for reporting this issue. There does appear to be a lot of inconsistency with the getPref... methods, so we'll be opening a bug to investigate possible fixes. This may end up being a breaking change to existing scripts, so we'll have to tread lightly. I'll attempt to better document what I found in a short investigation below.

 

In a nutshell, you can only access a given preference as a bool if the preference is of that type, which you can determine by looking at the preference .txt files. To explain further:

 

All preferences for After Effects are stored as strings in the .txt preference files. Within those files, the formatting determines their true data type as a boolean, long, etc. The getPref... methods perform coercion in some cases but not others, which leads to inconsistent behavior. To avoid this, look in the various .txt preference files for the preference you want to access and call the appropriate getter/setter method.

 

Here is a quick map of what each type looks like:

 

// This is a float, note the decimal point
"Speed" = "83.500000"

// This is a string
"Label Text ID 2 # 1" = "Red"

// This is a long, note the quotes
"Pref_SCRIPTING_FILE_NETWORK_SECURITY" = "1"

// This is a bool, without any quotes
"Enable Queue Notifications" = 00
 

 

 

There are other types in the preferences as well that do not correspond to these four types, but I need to dig in a bit more to see which method would be appropriate for them. I also noticed that calling the wrong method on some properties will wipe them out, which is a different bug that we'll also be investigating. 

 

Thanks again for reporting this issue,

- John, After Effects Engineering Team