tagPlugin: getObject at init()



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 29/04/2008 at 14:37, xxxxxxxx wrote:

    User Information:
    Cinema 4D Version:    
    Platform:      
    Language(s) :

    ---------
    Hi,

    im writing a small tag Plugin, but im having a hard time in the init function.

    at init i need to access the object that the tag is attached to, but i just cant seem to get it from the GeListNode that is passed in the init.

    i tried to cast the node some object, but when i start the plugin cinema always crashes..

    i tried like this, but its no good :(
    -----------
    Bool SplineMassTag::Init(GeListNode *node)
    {
         GePrint("Init..");

    BaseTag *tag = (BaseTag* )node;               
         int pointCount = ((PointObject* )tag->GetObject())->GetPointCount() :
    .
    .
    .

    what's wrong with that ?

    thanks,
    Daniel



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 29/04/2008 at 15:06, xxxxxxxx wrote:

    ok, after using the search a little more i decided to use the execute funtion instead by overriding the addtoexecute.

    now i want to access the points of the object:
    --------

    LONG SplineMassTag::Execute(PluginTag *tag, BaseDocument *doc, BaseObject *op, BaseThread *bt, LONG priority, LONG flags){
         GePrint("Execute..");
         GePrint("name: "+tag->GetObject()->GetTypeName());
         GePrint("points: "+((PointObject * )op)->GetPointCount());

    ------
    the name is printed alright, but not the pointcount.
    Is my cast wrong maybe ?



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 29/04/2008 at 15:17, xxxxxxxx wrote:

    Init() is not the best place for this. When loading Cinema 4D documents, it is not guaranteed that other things exist yet. And Init() is called before the tag is inserted into the object which means double trouble (boil and bubble).

    Instead, use the Message() method.

    Specifically MSG_MULTI_DOCUMENTIMPORTED will be sent after the document is loaded and everything is guaranteed to exist.

    When creating your tag on an object, the best course of action is to check for something like MSG_MENUPREPARE to do this initialization.



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 29/04/2008 at 15:19, xxxxxxxx wrote:

    1. Make sure that the object is indeed a PointObject (or derivative thereof like PolygonObject or SplineObject).

    2. LongToString(ToPoint(op)->GetPointCount()). GePrint doesn't do ANY conversion of types - it only knows String. There are LongToString() and RealToString() methods available.



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 29/04/2008 at 15:31, xxxxxxxx wrote:

    alright thanks alot.

    guess i have to dig alot deeper into the api...
    or make alot more posts ;|


Log in to reply