I want to get the fontsize using AEGP_ExecuteScript, but I don't how to use it,please give me an example. thanks!
Copy link to clipboard
There should be an example in the SDK if I recall correctly. But here's some background on it:
And here's an example:
AEGP_SuiteHandler suites(in_data->pica_basicP); A_Boolean outAvailablePB; AEGP_MemHandle outResultPH; AEGP_MemHandle outErrorStringPH; ERR(suites.UtilitySuite4()->AEGP_IsScriptingAvailable(&outAvailablePB)); ERR(suites.UtilitySuite4()->AEGP_ExecuteScript(NULL, "alert(123);", true, &outResultPH, &outErrorStringPH)); ERR(suites.MemorySuite1()->AEGP_FreeMemHandle(outResultPH)); ERR(suites.MemorySuite1()->AEGP_FreeMemHandle(outErrorStringPH));
ERR(suites.UtilitySuite4()->AEGP_ExecuteScript(NULL, "TextDocument.fontSize", true, &outResultPH, &outErrorStringPH));
Why this code execution failed, prompting that TextDocument could not be found?
And, how i can get text layer's fontSize or fillColor and so on?
I'd open new issues for fontSize / fillColor and so on. If you're getting "TextDocument could not be found" then ExtendScript is working, you just have to debug why that's missing etc for your specific app.
I use the AE SDK that i can call those functions, if i need import some sdk about script ？
You can either run scripts directly from C++ with this method, or just call the name of an existing script in ExtendScript that you've already created.
how can i read the fontSize value from outResultPH?
Here's what I have documented, it's been a while since I've tested it, but you basically need to lock the memory handle and then cast the value to an A_char, and then cast it to a string if you like.
A_char *res = NULL; ERR(suites.MemorySuite1()->AEGP_LockMemHandle(outResultPHs, reinterpret_cast<void**>(&res))); std::string strRes = res;
Thanks, your answer helped me a lot.