PDA

View Full Version : Testing Expression Plugin Tag Parent Class


Darter
01-01-2007, 08:48 PM
When I test an expression plugin tag by printing 'instanceof(tag, ExpressionPluginTag)', the result is '1' for the tag itself. However, when I use the same tag to test other expression plugin tags, the result is '0'. If I test the original tag from e.g. a COFFEE tag, the result is now '0'.

It seems that an expression plugin tag will correctly identify its own parent class using 'instanceof' but will give a false result for other tags of the same type. I'm wondering why this happens and whether this test can be reliably used when connecting an expression plugin tag with its User Data.

tcastudios
01-01-2007, 09:24 PM
For a regular COFFEE Tag to check if it is the one you are after, the only way (that I know of) is to check its name.
So you would then try search such as:

GetFirstTag(obj,name)
{
var tag = obj->GetFirstTag();
while (tag){
if (tag->GetName() == tostring(name)) return tag;
tag = tag->GetNext();
}
return NULL;
}

main(doc,op)
{

var ttag = GetFirstTag(op,"MyName");
if(!ttag)
return;

var myuserdata = ttag#ID_USERDATA:1;

if(!myuserdata) return
}


But I assume you are going to use "real" expression tags, so then you need a unique
ID to search for.
Either use the test range (1000001 to 1000010 I think, check SDK) or better get you own unique ID at PluginCafe.

So then it is:

GetFirstTag(obj,type)
{
var tag = obj->GetFirstTag();
while (tag){
if (tag->GetType() == type) return tag;
tag = tag->GetNext();
}
return NULL;
}


main(doc,op)
{
var ttag = GetFirstTag(op, ID);
if(!ttag) return;
var myuserdata = ttag#ID_USERDATA:1;
}



Cheers
Lennart

Darter
01-02-2007, 12:35 AM
Lennart, this works nicely.

Thanks for taking the time to arrange the code for me. I didnít realise that GetType() could be used with a plugin ID in this way - very useful.

This is for the Symmetry Clamp expression plugin tag. Iím planning to add User Data and present the tag for setting up via a scene file, in the same way as youíve done with Squeezer and GOGO/NONO. I like the AM integration that this gives, as opposed to a COFFEE dialog.

MrBraun
01-02-2007, 09:47 AM
Nice Darter: i see forward for the final relase! ;)

CGTalk Moderation
01-02-2007, 09:47 AM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.