Skip to main content
françois leroy
Inspiring
January 25, 2013
Question

Effect's index

  • January 25, 2013
  • 1 reply
  • 8445 views

Hi!

I have a problem to get an Effect's index. I tried to solve my problem by getting the Effect's name, and it works fine, except if user gives that name twice, so I'm still stucked...

How can you return the Effect's index, usable by Script? For example, my effect is the second effect applied on my layer, how can I get this "2" index?

I figured out how to get layer's index, comp's unique_ID, but see no reference for effect's index into the SDK documentation...

I also tried to iterate with AEGP_GetLayerNumEffects and compare effect_refH, but it doesn't work...

Does anyone know a way?

Thanx,

François

-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

I found a work around, by changing the name of my effect, calling it by script with the new name, then re-give the old name, but there must be something more simple...

Any idea?

Thanx

This topic has been closed for replies.

1 reply

Community Expert
January 26, 2013
françois leroy
Inspiring
January 27, 2013

Hi Shachar!

Thanx for the reply...

Well, it seems I did "not so bad", as i don't have to loop through the whole project, but it's still a bit surprising not to be able to access the index.

So, for those who need it, here's the process:

AEGP_RegisterWithAEGP -> get the plugin's ID

AEGP_GetNewEffectStreamByIndex -> get the stream of 1 parameter (no matter which one)

AEGP_GetNewParentStreamRef -> get the Effect's stream

AEGP_GetStreamName -> get the name (not the matchName)

AEGP_LockMemHandle -> store the OldName somewhere

AEGP_SetStreamName -> give a new Name

Then, you can access your effect by its name with Scripts... And your script can re-send you the Index if you need.

Rename your effect with the OldName, and dispose the streams.

By the way, I have a few more questions:

I've been testing some actions (changing a MaskShape) with Scripting, and directly from AEGP, and it seems scripting is faster. Do Script's engine and Effect's engine run at the same time?

And it leads to my 2nd question: is it possible to call ActionScript from an AEGP? Cos' it would be great to have 3 engines running at the same time to get a fast result...

And is it possible to call GPU calculations without switching to openGL?

That's a lot of questions, but you seem to have a lot of answers! :-)

Thanx!

François

françois leroy
Inspiring
June 8, 2013

yes... i see that now...

the code i posted is part of one of my plug-ins, and i tried to tidy it up

so it would fit the general case.

apparently, i didn't generalize it well enough, and some custom stuff was

left in...

the base address should be:

input->data;

that's a pointer to the first pixel of the buffer in any EffectWorldH;

also in my cdoe "rowBytes" represent "input->rowbytes". (no caiptal "B")

i'll try to re-edit my post...


Thanx Shachar, I got it workin' now.

So here is the code, for future generations

static PF_Err

LineProcessFunction( void                    *refcon,

                                                  A_long                    threadNum,

                                                  A_long                    iterationCount,

                                                  A_long                    numOfIterations)

{

     register MyData *data = (MyData*)refcon;

     PF_Err err = PF_Err_NONE;

           PF_Pixel *pixelDataInStart = reinterpret_cast <PF_Pixel *>(data->input.data);

           PF_Pixel *pixelDataOutStart = reinterpret_cast <PF_Pixel *>(data->output.data);

           PF_Pixel *inP =          pixelDataInStart + (iterationCount * (data->input.rowbytes / sizeof(PF_Pixel)));

           PF_Pixel *outP =          pixelDataOutStart + (iterationCount * (data->output.rowbytes / sizeof(PF_Pixel)));

                     for (int i = 0; i <  data->input.width; i++) {

                                        outP->alpha *=          inP->alpha;

                                        inP++;

                                        outP++;

          

  }

           return err;

}

Thanx again for your help!

François