Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Scripting: Retrieving Label Color from Preferences

  • Scripting: Retrieving Label Color from Preferences

    Posted by Jay Brown on July 26, 2017 at 9:43 pm

    I’ve been trying to figure this out the last couple of days and just can’t get by it.
    I’m trying to get the assigned preference Label Colors from the preference text file: “Adobe After Effects 14.2 Prefs-indep-general.txt”

    Here is a simplified version of what I got:
    var labelColor1 = app.preferences.getPrefAsString("Label Preference Color Section 5", "Label Color ID 2 # 1", PREFType.PREF_Type_MACHINE_INDEPENDENT);
    alert(labelColor1);

    It is returning ��88 when it should be retuning FFB5″88″
    Maybe it has something to do with the way it is being encoded when converted to a string or what.

    Anyways, any help would be greatly appreciated! ????

    Thanks,
    -Jay

    Jay Brown replied 8 years, 6 months ago 2 Members · 6 Replies
  • 6 Replies
  • Jay Brown

    July 28, 2017 at 2:01 am

    I ran a few tests and it seems as though getPrefAsString() imports anything surrounded in quotes fine, but struggles with characters outside of quotes. Sort of makes sense, in that whatever is in quotes is considered a string, not sure why it still retrieves some additional data though.

    Still looking for a solution. Not sure if savePrefAsString() could be used to add quotes to the existing pref text document or something like that, and then try to retrieve the string again? TBD!

  • Xavier Gomez

    July 29, 2017 at 9:10 am

    You could try getPrefAsLong(), which should produce a number.
    Most probably an integer in the range 0 – (255*255*255-1).
    Then you should convert that number to an array [R, G, B], all entries in the range 0-255, then divide all entries by 255 to get an array [r, g, b], entries in the range [0,1], which is what After Effects uses.
    I havent tried, but worth trying.

    Xavier.

  • Jay Brown

    August 1, 2017 at 11:08 pm

    Ahhh, okay I’ll give that a try
    The one time I need getPrefAsString and it only doesn’t work for this specific setting x_x

  • Xavier Gomez

    August 6, 2017 at 1:12 pm

    Sorry, i didnt check the thread much after writing to it.
    getPrefAslong doesnt work and, as you already said, getPrefAsString produces a string that is hardly usable.

    It seems that one can recover the actual hex color code from the string as written in the prefs file by converting everything that is in between quotes like this:

    function prefCodeToHexCode(str){
    return str.replace(/”([^”]+)”/g, function(u, code){
    var result = “”;
    for (var i=0; i

  • Xavier Gomez

    August 6, 2017 at 1:15 pm

    The code failed to be written correctly, and i can’t edit, so once again:

    function prefCodeToHexCode(str){
    return str.replace(/"([^"]+)"/g, function(u, code){
    var result = "";
    for (var i=0; i

  • Jay Brown

    October 24, 2017 at 6:09 pm

    Sorry I missed this and thanks so much for the reply Xavier!
    Took me a while to figure it how to search .txt file but finally got it working.
    Ended up having to remove the first two Fs from the string, then go through and convert just the quoted letters to HEX, add the sections back together and then convert the new completed HEX string to RGB from my purposes.
    Really odd how they don’t seem to want you recalling the colors ha

We use anonymous cookies to give you the best experience we can.
Our Privacy policy | GDPR Policy