Skip to main content
Richard Rosenman
Inspiring
January 21, 2022
Answered

Checking Out Layer Position

  • January 21, 2022
  • 1 reply
  • 2356 views

Hi gang;

 

This is probably a very silly question but if I check out a layer like so:

	AEFX_CLR_STRUCT(checkout);
	ERR(PF_CHECKOUT_PARAM(in_data,
		PARENT_LAYER_ID,
		in_data->current_time,
		in_data->time_step,
		in_data->time_scale,
		&checkout));

 

How do I retrieve it's position?

I know I can easily retrieve the layer's width and height like so:

 

int width = checkout.u.ld.width;
int height = checkout.u.ld.height;

 

I found in the documentation that I can use this to retrieve the origin, which I assume is what I want:

int originx = checkout.u.ld.origin_x;
int originy = checkout.u.ld.origin_y;

 

But these return 0. I basically want to retrieve a layer's position so that I can bind my effect to it's position.

Am I doing something wrong?

 

Thanks,

-Richard

This topic has been closed for replies.
Correct answer shachar carmi

Hi Shachar;

 

You've been more than helpful and I'd understand if you've hard enough but... on the off-chance you haven't:

 

Your suggestion did in fact, resolve the crash. The result is a different error message pop-up upon plugin launch, as well as the effect never getting drawn at all:

 

After Effects error: zero denominator converting ratio denominators. (17 :: 19)

 

I Googled this but a number of totally unrelated issues came up, some having to do with framerate (which has nothing to do with my plugin).

 

And upon stepping through with the debugger, this is the feedback:

 

&thisTime	0x0000000048e5b1a0 {value=1 scale=0 }	A_Time *
&val	0x0000000048e5b540 {streamH=0x00000000685e91e0 {Camera Raw.8bi!0x0000000053535353 {...}} val={four_d=...} }	AEGP_StreamValue2 *
AEGP_LTimeMode_LayerTime	AEGP_LTimeMode_LayerTime (0)	<unnamed-enum-AEGP_LTimeMode_LayerTime>
ERR	0	unsigned int
globalID	0	long
stream	0x00000000685e91e0 {Camera Raw.8bi!0x0000000053535353 {...}}	_AEGPp_Stream * *
suites	{i_pica_basicP=U.dll!0x0000000008165d30 {AcquireSuite=U.dll!0x00000000080b9ab0 ReleaseSuite=U.dll!0x00000000080ba0a0 ...} ...}	AEGP_SuiteHandler
val	{streamH=0x00000000685e91e0 {Camera Raw.8bi!0x0000000053535353 {...}} val={four_d=0x0000000048e5b548 {...} ...} }	AEGP_StreamValue2
val.streamH	0x00000000685e91e0 {Camera Raw.8bi!0x0000000053535353 {...}}	_AEGPp_Stream * *

Again, I understand if this is just too tedious to resolve but if this gives you any other thoughts, please do share. I'd love to get this AEGP example working, so I can apply it to all the others moving forward.

 

Thanks,

-Rich


&thisTime 0x0000000048e5b1a0 {value=1 scale=0 }

time scale can't be 0.

1 reply

Community Expert
January 21, 2022

origin_x and y will give you the layer's 0,0 location in the grabbed buffer. it won't give you the layer's width and height.

i do the following (perhpas there' a better way):

1. get the layer param's value using AEGP_GetNewStreamValue();

2. the gotten value will contain an AEGP_LayerIDVal. use it with AEGP_GetLayerFromLayerID.

3. now use AEGP_GetLayerSourceItem to obatin the layer's source object.

4. and finally, AEGP_GetItemDimensions will get you the layer's source item's dimensions.

Richard Rosenman
Inspiring
May 20, 2022

Hi guys;

 

I am coming back to this thread, now working with the AEGP suite as Shachar suggested, and trying to understand it. I have followed many of the snippets and documentation to set up the following code.

 

First, in the global section of my plugin, I define the plugin ID. Just like the ProjDumper project, this is literally right after the include files are specified near the top, and not placed in any function.

 

static	AEGP_PluginID	globalID = 0;

 

Then, in my render function, I use the following code to attempt to retrieve the active layer's x & y POSITION:

 

AEGP_LayerH layerPH;
A_Time* thisTime;
AEGP_LTimeMode timeMode = AEGP_LTimeMode_LayerTime;
AEGP_StreamRefH stream = NULL;
AEGP_TwoDVal value;

ERR(suites.LayerSuite5()->AEGP_GetActiveLayer(&layerPH));

ERR(suites.DynamicStreamSuite2()->AEGP_GetNewStreamRefForLayer(globalID, layerPH, &stream));

ERR(suites.StreamSuite4()->AEGP_GetNewLayerStream(globalID, layerPH, AEGP_LayerStream_POSITION, &stream));

AEGP_StreamValue2 val;

AEGP_StreamValue2* sample_val = &val;

AEFX_CLR_STRUCT(val);

val.streamH = stream;

ERR(suites.StreamSuite4()->AEGP_GetNewStreamValue(globalID, stream, AEGP_LTimeMode_LayerTime, thisTime, FALSE, &val));

value.x = val.val.two_d.x;

value.y = val.val.two_d.y;

ERR(suites.StreamSuite4()->AEGP_DisposeStreamValue(&val));

ERR(suites.StreamSuite4()->AEGP_DisposeStream(stream));

 

I want to retrieve the layer's x & y position and place it into value.x and value.y. Unfortunately, this code results in a spectacular & celebratory crash! Any suggestions on why?

 

Eventually, I will want to assign the layerPH to a dropdown layer parameter.

 

Any thoughts? James, I am using an older SDK so I can't use your suggestion.

 

I have used these two threads as reference:

 

https://community.adobe.com/t5/after-effects-discussions/keep-getting-quot-internal-verification-failure-no-current-context-quot-error-when-using-stream/m-p/7981402

 

https://community.adobe.com/t5/after-effects-discussions/how-to-get-layer-transform-data-in-plugin/m-p/11616280

 

Regards,

-Richard

Community Expert
May 20, 2022

what crash message are you getting? can you tell which specific line is causing the crash?