3 Replies Latest reply: Apr 19, 2011 10:50 PM by cbmb RSS

    Text justification using AEGP

    cbmb Community Member

      Is it possible to retrieve the text justification of a text layer using AEGP suites ?

       

      The jsx equivalent is

      var just = layer.property("ADBE Text Properties").property("ADBE Text Document").value.justification;

       

      Thanks

        • 1. Re: Text justification using AEGP
          shachar carmi Community Member

          i really don't see a way to do that with from the c++ API.

           

          you can however do:

          AEGP_ExecuteScript("layer.property("ADBE Text Properties").property("ADBE Text Document").value.justification");

           

          that will execute the text as a script from within an effect (or AEGP).

          very handy actually.

          :-)

          • 2. Re: Text justification using AEGP
            gutsblow Community Member

            @shachar AEGP_ExecuteScript executes Javascript, but can we get return values from it? I think the user asked how to get the Text Justification value.

            • 3. Re: Text justification using AEGP
              cbmb Community Member

              Thanks.

               

              Of course that's only a workaround, but the ExecuteScript trick seems to work fine.

               

              (script string)

              #define TEXT_JUSTIFICATION_SCRIPT "function getTextJustificationForLayer(layerId) { \
                   var comp = app.project.activeItem; \
                   for (var i = 0; i < comp.numLayers; i++) \
                        if (i == layerId && comp.layer(i+1) instanceof TextLayer) \
                             return comp.layer(i+1).property(\"ADBE Text Properties\").property(\"ADBE Text Document\").value.justification; \
              } \
              getTextJustificationForLayer(%d);"

               

               

              (somewhere in the code)

              AEGP_MemHandle     resultMemH          =     NULL;
              A_char          *resultAC          =     NULL;
              A_char          scriptAC[AEGP_MAX_MARKER_URL_SIZE] = {'\0'};
                   
              sprintf(scriptAC, TEXT_JUSTIFICATION_SCRIPT, layerIndex);
              ERR(suites.UtilitySuite5()->AEGP_ExecuteScript(S_my_id, scriptAC, FALSE, &resultMemH, NULL));
              ERR(suites.MemorySuite1()->AEGP_LockMemHandle(resultMemH, reinterpret_cast<void**>(&resultAC)));
                   
              // get justification constant (6012,6013,6014)
              int just = atoi(resultAC);
                   
              ERR(suites.MemorySuite1()->AEGP_FreeMemHandle(resultMemH));