Checking Out Layer Position

Explorer ,
Jan 20, 2022 Jan 20, 2022

Copy link to clipboard

Copied

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

TOPICS
SDK

Views

165

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 , May 21, 2022 May 21, 2022
&thisTime 0x0000000048e5b1a0 {value=1 scale=0 } time scale can't be 0.

Likes

Translate

Translate
Adobe Community Professional ,
Jan 20, 2022 Jan 20, 2022

Copy link to clipboard

Copied

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.

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 ,
Jan 21, 2022 Jan 21, 2022

Copy link to clipboard

Copied

Hi Shachar!

 

Thanks for your reply as always!

 

Actually, I'm interested in the grabbed layer's position, not size, so that I can bind my effect to it. Kind of like using the pickwhip in After Effects to link one item's position to another. Can that be done with:

 

checkout.u.ld.origin_x;

 

However, when I use it, I just get 0.0 no matter where I move the grabbed layer.

 

Any suggestions?

 

Thanks,

Richard 

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 ,
Jan 21, 2022 Jan 21, 2022

Copy link to clipboard

Copied

AEGP_GetNewLayerStream with AEGP_LayerStream_POSITION.

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
Contributor ,
Jan 23, 2022 Jan 23, 2022

Copy link to clipboard

Copied

I will add to this that you may want to use layer2World to get the data as it accounts for any parented xforms. A convenience function to decompose the matrix is only available in AE CC17 and up (AEGP Math suite)

 

 

 

 

AEGP_SuiteHandler suites(in_data->pica_basicP);
    
    AEGP_LayerH layerH = NULL;
    A_Matrix4 layer2WorldMat; AEFX_CLR_STRUCT(layer2WorldMat);
    A_Time curTime; AEFX_CLR_STRUCT(curTime);
    A_FloatPoint3 posVP, scaleVP, shearVP, rotVP; // rotation is measured in radians

    curTime.value = in_data->current_time;
    curTime.scale = in_data->time_scale;

    suites.PFInterfaceSuite1()->AEGP_GetEffectLayer(in_data->effect_ref, &layerH); //get the layer refference
    suites.LayerSuite7()->AEGP_GetLayerToWorldXform(layerH, &curTime, &layer2WorldMat);
    suites.MathSuite1()->AEGP_MatrixDecompose4(&layer2WorldMat, &posVP, &scaleVP, &shearVP, &rotVP);

 

 

 

 

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 ,
May 19, 2022 May 19, 2022

Copy link to clipboard

Copied

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

 

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

 

Regards,

-Richard

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 ,
May 20, 2022 May 20, 2022

Copy link to clipboard

Copied

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

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 ,
May 20, 2022 May 20, 2022

Copy link to clipboard

Copied

Hi Shachar;

 

Thanks for your reply. I get an immediate crash as soon as I apply the effect. No warning... nothing.

 

If I comment out this line, I do not get a crash, although other issues come up like my effect isn't drawn. But at least it doesn't crash and it show improvement.

 

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

 

Any ideas why? Does my code look correct upon first glance?

 

Regards,

-Rich

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 ,
May 21, 2022 May 21, 2022

Copy link to clipboard

Copied

at a glance, it all looks ok. did you set a breakpoint at the begning of this funciton and walked though it? did you take a bpeek at the gotten values and addresses?

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 ,
May 21, 2022 May 21, 2022

Copy link to clipboard

Copied

Hi Shachar;

 

If I step through it with the debugger, this is the output for the breakpoint right before the crash:

 

stream	0x00000000683ef0c0 {0x00007ff853535353 {...}}	_AEGPp_Stream * *
val	{streamH=0x0000000000000000 {???} val={four_d=0x00000000465bb638 {0.0000000000000000, 0.0000000000000000, ...} ...} }	AEGP_StreamValue2
streamH	0x0000000000000000 {???}	_AEGPp_Stream * *
val	{four_d=0x00000000465bb638 {0.0000000000000000, 0.0000000000000000, 0.0000000000000000, 0.0000000000000000} ...}	AEGP_StreamVal2
val.streamH	0x0000000000000000 {???}	_AEGPp_Stream * *

 

val.streamH is passed to the line that crashes it and many of these variables are zero, which looks fishy.

 

And then if I press continue, and it reaches the crash line, VS reports an exception thrown at the crash line and this is the output:

 

&val	0x00000000465bb630 {streamH=0x00000000683ef0c0 {0x00007ff853535353 {...}} val={four_d=0x00000000465bb638 {...} ...} }	AEGP_StreamValue2 *
AEGP_LTimeMode_LayerTime	AEGP_LTimeMode_LayerTime (0)	<unnamed-enum-AEGP_LTimeMode_LayerTime>
ERR	0	unsigned int
globalID	0	long
stream	0x00000000683ef0c0 {0x00007ff853535353 {...}}	_AEGPp_Stream * *
suites	{i_pica_basicP=U.dll!0x0000000007c75d30 {AcquireSuite=U.dll!0x0000000007bc9ab0 ReleaseSuite=U.dll!0x0000000007bca0a0 ...} ...}	AEGP_SuiteHandler
thisTime	0x0000000000000001 {value=??? scale=??? }	A_Time *
val	{streamH=0x00000000683ef0c0 {0x00007ff853535353 {...}} val={four_d=0x00000000465bb638 {0.0000000000000000, ...} ...} }	AEGP_StreamValue2
streamH	0x00000000683ef0c0 {0x00007ff853535353 {...}}	_AEGPp_Stream * *
val	{four_d=0x00000000465bb638 {0.0000000000000000, 0.0000000000000000, 0.0000000000000000, 0.0000000000000000} ...}	AEGP_StreamVal2
val.streamH	0x00000000683ef0c0 {0x00007ff853535353 {...}}	_AEGPp_Stream * *

Unfortunately, I don't understand a lot of this but does it shed any light to you about what's happening?

 

I appreciate your help, as always.

 

Thanks,

-Richard

 

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 ,
May 21, 2022 May 21, 2022

Copy link to clipboard

Copied

it actual exposed the reason. 🙂

A_Time* thisTime;

should be:

A_Time thisTime;

 

and when used in AEGP_GetNewStreamValue, it should be "&thisTime" instead of "thisTime".

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 ,
May 21, 2022 May 21, 2022

Copy link to clipboard

Copied

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

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 ,
May 21, 2022 May 21, 2022

Copy link to clipboard

Copied

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

time scale can't be 0.

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 ,
May 21, 2022 May 21, 2022

Copy link to clipboard

Copied

Shachar;

 

I'm so close... this fix you provided now correctly returns the current layer's x & y position. If I move my canvas over and check its position in AE, its at 475 & 311. And when I check in the debugger, val.val.two.d.x returns 475 and val.val.two.d.y returns 311. So it works! Thank you!

 

BUT, my effect doesn't get drawn. Just a blank canvas. If I comment out all the streaming code, it draws my effect just fine. I will take it from here and try to figure out why but if you have come across this before, or have any suggestions, please do let me know! 

 

val	{streamH=0x000000004fd52b30 {Camera Raw.8bi!0x0000000053535353 {...}} val={four_d=0x00000000476bb548 {...} ...} }	AEGP_StreamValue2
val.val	{four_d=0x00000000476bb548 {475.00000000000000, 311.00000000000000, 0.0000000000000000, 0.0000000000000000} ...}	AEGP_StreamVal2
val.val.two_d	{x=475.00000000000000 y=311.00000000000000 }	AEGP_TwoDVal
val.val.two_d.x	475.00000000000000	double
val.val.two_d.y	311.00000000000000	double
value	{x=475.00000000000000 y=8.711403253613e-315#DEN }	AEGP_TwoDVal
value.x	475.00000000000000	double
value.y	8.711403253613e-315#DEN	double

 I will mark your answer as correct in the meantime. Thank you!

 

Regards,

-Rich

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 ,
May 22, 2022 May 22, 2022

Copy link to clipboard

Copied

LATEST

perhaps one of these two lines return an error code:

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

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

 

if so, then non of the downstream code wrapped in ERR() will be executed. this macro writes the error code into the err variable. check it's content after each line.

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