Skip to main content
January 22, 2010
Question

How do I set text from an effect?

  • January 22, 2010
  • 4 replies
  • 1420 views

How do I write an effect to set the text on a text layer?  The text functions appear to be part of the AEGP suites.  I've tried to access these from my effect, in both the 'FrameSetup()' and 'Render()' functions, the text doesn't appear.

Since there are text effects that come with After Effects, it must be possible.  I must be overlooking something fundamental.

Thanks,

Bob Bales

This topic has been closed for replies.

4 replies

January 25, 2010

This works fine, after I added the 'AEGP_SetStreamValue()' call.  However, I did not find a way to create a new 'AEGP_StreamValue' that includes (eventually) the proper 'AEGP_TextDocumentH' structure.  I still call 'AEGP_GetNewStreamValue()' to get an object to modify.

Thanks for all the help,

Bob Bales

Community Expert
January 25, 2010

i swear to god, you don't need AEGP_GetNewStreamValue();

AEGP_GetNewLayerStream()  gets you the handle you need.

you declare a new AEGP_StreamValue2, fill it with content, and go directly to AEGP_SetStreamValue().

you don't dispose of the value, only of the AEGP_StreamRef.

the code should look like:

AEGP_GetEffectLayer();

AEGP_GetNewLayerStream();

//creating a new, empty valueP, and filling it with text.

AEGP_StreamValue2  valueP;
AEGP_SetText("blah blah blah", &valueP);//that's not the correct syntax but you get the point.
//putting that valueP into the gotten layer stream.
AEGP_SetStreamValue(streamRefH, valueP);//again, wrong syntax...
//disposing only of the layer stream. not of the valueP.
AEGP_DisposeStream();

January 22, 2010

Thanks.  I'll try it.  This helps me understand a little more about how everything fits together.

Bob Bales

January 22, 2010

Thanks,

I basically copied from the "Trxt Twiddler" sample.  My sequence of calls (with appeopriate suite pointers and arguments) is:

AEGP_GetEffectLayer();

AEGP_GetNewLayerStream();

GetNewStreamValue();

AEGP_SetText(

);

AEGP_DisposeStreamValue(

);

AEGP_DisposeStream();

If this is correct, I;ll start checking the values of the arguments.

Thanks,

Bob Bales

Community Expert
January 22, 2010

something is wrong here.

GetNewStreamValue();

AEGP_SetText(

);

AEGP_DisposeStreamValue(

);

you should use SetStreamValue() instead of GetNewStreamValue.

you use "get" to find out what already on the layer, and "set" to replace the old content with the new.

so unless you're really trying to read the old content, you don't need GetNewStreamValue().

furthermore you should first call AEGP_SetText and only then the SetStreamValue().

to be precise:

first you create a new AEGP_StreamValue2.

then you use AEGP_SetText to put the new text into the AEGP_StreamValue2 structure.

only then you should use SetStreamValue() to put the content of the AEGP_StreamValue2 into the text layer.

if indeed you're using SetStreamValue() instead of GetNewStreamValue() then you don't need to use AEGP_DisposeStreamValue.

you only need to dispose of stream values you have read, not those you create from scratch and put into streams.

as for the values you used for the arguments, they're probably correct.

any mistake there would have launched a very loud error from AE.

Community Expert
January 22, 2010

hi bob,

i'm assuming you've used AEGP_SetText and AEGP_SetStreamValue to put the new text in the layer.

for all i know, it should work from within effects.

i use AEGP_SetStreamValue during the render call with no problems.

it's possible though that the text change works, but the layer doesn't get invalidated, so you don't see the change until something forces a re-render of that layer. (perhaps even purging of the image caches)

is that effect applied on the same text layer you're trying to affect?

that might be a problem, because if during the render you change the same layer you're on, you're actually invalidating the render in progress...

what is the process you're doing?

maybe if i knew the bigger picture i could help you find the problem.
p.s.
did you take a look at the Text_Twiddler sample?
it changes the text in text layers.