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

Effect's index

  • January 25, 2013
  • 1 reply
  • 8539 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

Community Expert
January 27, 2013

that whole changing-the-effect's-name-and-back thing seems a bit shady to me, as it creates a change in the project for the sole purpose of finding the index...

you could check some piece of sequence_data to tell if your check has hit the right instance, or better yet, a PUI_ONLY hidden param, who's changes don't falg the project as "dirty".

but as long as you're happy with your solution, i'm happy. :-)

as for sciprts running while a plug-in is executing,

as far as i know, only one API is active at a time.

you can call a script from within a plug-in, but that plug-in will hold until the script returns.

same goes for actions script. i guess you can call it from within your plug-in and even from a javascript ran from within a plug-in, but as far as i know, their operations will queue, and not parallel.

about scripts changing masks faster than the API,

the script engine is a plug-in, much like any other AEGP. as far as i know, to maniuplate the project, the script plug-in translates the java commands to the C++ api commands that we all use.

so pehaps the extra speed is because the JS loop uses the C API more efficiently than the C++ loop you created.

if you're keyframing the mask shape, then perhaps it's a matter of using StartAddKeyframes(). it's supposed to make a big difference in performance hen adding a mass amount of keys.

GPU-wise,

i'm not too experienced with it. there are some other guys in the forum whore are far more familiar with openGL than me.

what i can tell you is that like any other facility the computer has, you can access the GPU using AE's API, or you can access it yourself directly.

so a plug-in doesn't have to be all around GPU based, to use the GPU.

even if you do use AE's access of the GPU, you still can do as much CPU calculations as you'd like. you don't HAVE to be polite and use up your declared intention of using the GPU.

not all your questions were fully answered,

but i hope some of that helps you make some sense of whole thing.