How to use AEGP_ExecuteScript?

New Here ,
Dec 21, 2021 Dec 21, 2021

Copy link to clipboard

Copied

I want to get the fontsize using AEGP_ExecuteScript, but I don't how to use it,please give me an example.  thanks!

TOPICS
Scripting , SDK

Views

197

Likes

Translate

Translate

Report

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

Adobe Community Professional , Jan 06, 2022 Jan 06, 2022

There should be an example in the SDK if I recall correctly. But here's some background on it:

https://ae-plugins.docsforadobe.dev/aegps/aegp-suites.html?highlight=AEGP_ExecuteScript#aegp-utilitysuite6

 

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);
...

Likes

Translate

Translate
Adobe Community Professional ,
Jan 06, 2022 Jan 06, 2022

Copy link to clipboard

Copied

There should be an example in the SDK if I recall correctly. But here's some background on it:

https://ae-plugins.docsforadobe.dev/aegps/aegp-suites.html?highlight=AEGP_ExecuteScript#aegp-utility...

 

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));

Likes

Translate

Translate

Report

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
New Here ,
Feb 09, 2022 Feb 09, 2022

Copy link to clipboard

Copied

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?

Likes

Translate

Translate

Report

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
Adobe Community Professional ,
Feb 09, 2022 Feb 09, 2022

Copy link to clipboard

Copied

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.

Likes

Translate

Translate

Report

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
New Here ,
Feb 11, 2022 Feb 11, 2022

Copy link to clipboard

Copied

I use the AE SDK that i can call those functions, if i need import some sdk about script ? 

Likes

Translate

Translate

Report

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
Adobe Community Professional ,
Feb 11, 2022 Feb 11, 2022

Copy link to clipboard

Copied

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.

Likes

Translate

Translate

Report

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 ,
Mar 07, 2022 Mar 07, 2022

Copy link to clipboard

Copied

how can i read the fontSize value from outResultPH?

Likes

Translate

Translate

Report

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
Adobe Community Professional ,
Mar 07, 2022 Mar 07, 2022

Copy link to clipboard

Copied

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;

 

Likes

Translate

Translate

Report

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 ,
Mar 07, 2022 Mar 07, 2022

Copy link to clipboard

Copied

LATEST

Thanks, your answer helped me a lot. 

Likes

Translate

Translate

Report

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