Help Creating a NULL in SDK
Copy link to clipboard
Copied
Hi gang;
So I need to create a Null layer from within my plugin, and link a point parameter to it. I've never done this before but my understanding is that it needs to be done via Javascript. I thought I had the creation part done but it crashes upon execution. This is what I have:
AEGP_SuiteHandler suites(in_data->pica_basicP);
A_Boolean outAvailablePB;
AEGP_MemHandle outResultPH;
AEGP_MemHandle outErrorStringPH;
const char* javascriptCode =
"var comp = app.project.activeItem;\r\n"
"comp.layers.addNull();\r\n";
ERR(suites.UtilitySuite4()->AEGP_IsScriptingAvailable(&outAvailablePB));
ERR(suites.UtilitySuite4()->AEGP_ExecuteScript(NULL, javascriptCode, true, &outResultPH, &outErrorStringPH));
A_char* result = NULL;
ERR(suites.MemorySuite1()->AEGP_LockMemHandle(outResultPH, reinterpret_cast<void**>(&result)));
ERR(suites.MemorySuite1()->AEGP_FreeMemHandle(outResultPH));
ERR(suites.MemorySuite1()->AEGP_FreeMemHandle(outErrorStringPH));
Any suggestions as to what is wrong here?
I haven't done the linking part but I have a question about that too. Is that a separate javascript command that must be sent after creating the Null or can it be combined together with the Null creation?
Thanks in advance.
Richard
Copy link to clipboard
Copied
1. on what line does your code crash?
2. not that i think it's the problem, but you're not checking the state of outAvailablePB before conditionally calling the script.
3. you're not checking if outResultPH is non null before locking it.
4. you can use AEGP_CreateNullInComp instead of javascript, if you'd like...

