Jump to content

Associations equivalent in C++


Cmb

Recommended Posts

Hello !

I'd like to know if there is an equivalent as this method in Vectorscript in the SDK

AddAssociation(obj1, kOnDeleteDelete, obj2);

or what is the best way to have the same behavior, as I want to delete a child when an Object is removed.

 

I also tried to catch the event in VWParametric_EventSink, but can't find a virtual for that.

Is there a way to do this without having to override :

virtual Sint32 VCOM_CALLTYPE	Execute(ParametricMessage* message);

 

Thanks

Link to comment

You can add an association with Kludge.  I couldn't find a way to remove an association, so I call VS.

    // ------------------------------------------------------------------------------------------------------
    void AddDeleteAssociation(MCObjectHandle FromObject, MCObjectHandle ToObject)
    {
        PluginLibraryArgTable argTable;
        argTable.args[0].argType = kHandleArgType;
        argTable.args[0].handleValue  = FromObject;
        argTable.args[1].argType = kIntegerArgType;
        argTable.args[1].intValue   = 4;
        argTable.args[2].argType = kHandleArgType;
        argTable.args[2].handleValue  = ToObject;
        
        EPE_Kludge in( EPE_Kludge::kKludgeAddAssociation, & argTable );
        ::GS_Kludge( gCBP, EPE_Kludge::kKludgeSelector, & in, nil ) && argTable.functionResult.boolValue;;
    }
    
    void RemoveDeleteAssociation(MCObjectHandle FromObject, MCObjectHandle ToObject)
    {
        PluginLibraryArgTable argTable;
        argTable.args[0].argType = kHandleArgType;
        argTable.args[0].handleValue  = ToObject;
        argTable.args[1].argType = kIntegerArgType;
        argTable.args[1].intValue   = 4;
        argTable.args[2].argType = kHandleArgType;
        argTable.args[2].handleValue  = FromObject;
        
        gSDK->CallPluginLibrary("RemoveAssociation", &argTable, 0);
    }
    // ------------------------------------------------------------------------------------------------------

If you want to handle deletions on the event level, look at the UpdateSupport example in the SDK.  The update manager runs independently of the plug-in objects, so it can handle deletions.

  • Like 1
Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...