Skip to main content
May 13, 2010
Answered

Refresh Issue in my Effect Plugin

  • May 13, 2010
  • 1 reply
  • 3125 views

Hi,

I'm writing a small effect plugin, where i have one or two color pickers in the UI.

The layer i'm applying the effect will be PreComp (with 2 layers inside). So whenever i change the color in my effect, that color should be updated to the Fill Effect of corresponding layers inside PreComp if they have any.

What i mean is if i change the color value in first color picker, it has to change the fill effect color for first layer inside that PreComp. And same goes with second.

I know its bit confusing.

Now my problem is color doesn't update properly. Sometimes it works and sometimes it doesn't.

I tried sending PF_OutFlag_REFRESH_UI, but it doesn't work. May be this will refresh only current Comp.

Thanks and Regards,

Suma

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

are you sure about that params[i + 1] thing?

as far as i could tell from your code i is the number of layer in the comp.

are you sure the number of layer and the param index are really off by 1?

another thing,

are you using smart fx?

if so then the color param has to be checked out during pre-render, or you might not have it's reuslts during render time.


oh!

and you can always read the color param on your effect by using AEGP_GetNewStreamValue.

yes i know, you can get it via the params[] array,

but this way you don't have to check it out in advance during pre-render, and you get float values that HAVE to be compatible with those you set in the fill effect.

maybe that's the way to go for you, since it only happens when the user changes something, and not on every render operations,

so you don't mind the process being a bit wasteful.

1 reply

Community Expert
May 13, 2010

during what call do you make thse changes?

are you using param supervision? because that would be a good way to do that.

what method are you using to change the color values?

different methods call for different ways of updating the UI...

i need more info to be ab;e to help on this one.

could you post a brief walk thorugh of the process and the methods involvoed?

May 13, 2010

Yes i'm using param supervision. When it comes to PF_Cmd_USER_CHANGED_PARAM i do the following. I know i have to update only param which is changed, but currently i update all layer's fill effects when it comes to my func

This is what i'm doing.

    AEGP_GlobalRefcon globalRef=NULL;
    const A_char* pluginName = "Convolutrix";
    AEGP_PluginID pluginID;
    suites.UtilitySuite5()->AEGP_RegisterWithAEGP( globalRef, pluginName, &pluginID );
   
    AEGP_LayerH activeLay = NULL;
   
    suites.LayerSuite5()->AEGP_GetActiveLayer(&activeLay);
               
    AEGP_ItemH item = NULL;
    suites.LayerSuite5()->AEGP_GetLayerSourceItem(activeLay, &item);


    AEGP_ItemType type;
    suites.ItemSuite7()->AEGP_GetItemType(item, &type);
   
    if(type == AEGP_ItemType_COMP)
    {
        AEGP_CompH preComp;
        A_Err err = suites.CompSuite6()->AEGP_GetCompFromItem(item, &preComp);
       
        if(err == noErr)
        {
            A_long numOfLay;
            suites.LayerSuite5()->AEGP_GetCompNumLayers(preComp, &numOfLay);
           
            for(A_long i = 0; i < numOfLay; i++)
            {
                AEGP_LayerH lay;
                suites.LayerSuite5()->AEGP_GetCompLayerByIndex(preComp, i, &lay);
               
                A_long numOfEff;
                suites.EffectSuite3()->AEGP_GetLayerNumEffects(lay, &numOfEff);
               
                for(A_long j = 0; j < numOfEff; j++)
                {
                    AEGP_EffectRefH eff;
                    suites.EffectSuite3()->AEGP_GetLayerEffectByIndex(pluginID, lay, j, &eff);
                   
                    AEGP_InstalledEffectKey key;
                    suites.EffectSuite3()->AEGP_GetInstalledKeyFromLayerEffect(eff, &key);
                   
                    char *name = new char();
                    suites.EffectSuite3()->AEGP_GetEffectMatchName(key, name);
                   
                    if(strcmp(name, (const char *)("ADBE Fill")) == 0)
                    {
                        AEGP_StreamRefH streamRef;
                        suites.StreamSuite3()->AEGP_GetNewEffectStreamByIndex(pluginID, eff, 3, &streamRef);
                       
                        AEGP_StreamType type;
                        suites.StreamSuite3()->AEGP_GetStreamType(streamRef, &type);
                       
                        AEGP_StreamValue2 val;
                        A_Time tim;
                        tim.value = in_data->current_time;
                        tim.scale = in_data->time_scale;
                        suites.StreamSuite3()->AEGP_GetNewStreamValue(pluginID, streamRef, AEGP_LTimeMode_CompTime,
                                                                      &tim,
                                                                      true, &val);
                       
                        val.val.color.alphaF = params[i + 1]->u.cd.value.alpha;
                        val.val.color.redF = params[i + 1]->u.cd.value.red;
                        val.val.color.greenF = params[i + 1]->u.cd.value.green;
                        val.val.color.blueF = params[i + 1]->u.cd.value.blue;
                       
                        suites.StreamSuite3()->AEGP_SetStreamValue(pluginID, streamRef, &val);
                       
                    }
                }
            }
        }
       
       
    }

Community Expert
May 13, 2010

a couple of things.

1. instead of using AEGP_GetActiveLayer you should use AEGP_GetEffectLayer.

the effect your layer is on isn't guaranteed to be the active layer.

2. you don't need to use AEGP_GetNewStreamValue before AEGP_SetStreamValue.

seriously.

these two have nothing to do with each other.

if you don't need to use the value, don' t read it. just write it.

if you do read it, you HAVE to dispose of it using AEGP_DisposeStreamValue.

these two pointers are minor things.

they could be the reason for the partial failiure in updating the UI,

but it's likely the problem is something else.

you didn't post the part of the code in which you request the UI update, so i can't tell if it's done right or not.

are you trying to update your effect's UI, or the fill effetcs UI?