Skip to main content
Richard Rosenman
Inspiring
May 11, 2024
Question

Help Creating a NULL in SDK

  • May 11, 2024
  • 1 reply
  • 253 views

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

This topic has been closed for replies.

1 reply

Community Expert
May 11, 2024

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