BitmapButton toggle id

On 26/05/2013 at 07:06, xxxxxxxx wrote:

Hi,

can anyone point me to the correct BFM_MESSAGE id to call a toggle BitmapButton click in a 
GeDialog / toggle its state ? I have that code which does work in general (it does disable 
the button, but i want to toggle it as described).

def Execute(self, doc) :
    fhPolyTools.ID_ISFROZEN = not fhPolyTools.ID_ISFROZEN
    tool = plugins.FindPlugin(doc.GetAction(), c4d.PLUGINTYPE_TOOL)
    if isinstance(tool, plugins.BasePlugin) :
        data = tool.GetNodeData()
        if isinstance(data, fhBaseSelectToolData.fhBaseSelectToolData) :
            if isinstance(data.Dialog, gui.GeDialog) :
                print data.Dialog.SendMessage(id   = fhPolyTools.IDC_BASE_FREEZE_BTN, 
                                              msg  = c4d.BaseContainer(c4d.BFM_DISABLE))
    return True

Thank you for your help and happy rendering,

Ferdinand

On 26/05/2013 at 07:37, xxxxxxxx wrote:

hm,

that is how i thonk it should work, but it does not 🤢.

def Execute(self, doc) :
    fhPolyTools.ID_ISFROZEN = not fhPolyTools.ID_ISFROZEN
    tool = plugins.FindPlugin(doc.GetAction(), c4d.PLUGINTYPE_TOOL)
    if isinstance(tool, plugins.BasePlugin) :
        data = tool.GetNodeData()
        if isinstance(data, fhBaseSelectToolData.fhBaseSelectToolData) :
            if isinstance(data.Dialog, gui.GeDialog) :
                msg, bc = c4d.BaseContainer(c4d.BFM_VALUECHNG), c4d.BaseContainer(c4d.BFM_ACTION)
                bc.SetLong(c4d.BFM_ACTION_ID, fhPolyTools.IDC_BASE_FREEZE_BTN)
                bc.SetBool(c4d.BFM_ACTION_VALUE, fhPolyTools.ID_ISFROZEN)
                msg.SetContainer(c4d.BFM_ACTION, bc)
                data.Dialog.SendMessage(id = fhPolyTools.IDC_BASE_FREEZE_BTN, msg = msg)
    return True

On 26/05/2013 at 07:48, xxxxxxxx wrote:

Never tried it with Python.
My C++ notes say to use it like this:

BaseContainer msg(BFM_ACTION);  
msg.SetLong(BFM_ACTION_ID, YOUR_ID);  
msg.SetLong(BFM_ACTION_VALUE, TRUE);

-ScottA

On 26/05/2013 at 07:56, xxxxxxxx wrote:

Hi scott,

thanks for your answer. I tried that too, using SetLong for BFM_ACTION_VALUE and sending the BMF_ACTION container directly, but that did not work either for me.

On 26/05/2013 at 08:27, xxxxxxxx wrote:

You're asking about GeDialog. Yet the code you posted is for a Tool Data plugin?
Are you trying to send a message from a tool plugin to a GeDialog plugin?

Also.
BitmapButtons have their own settings to do things like TOGGLE: _  customgui_bitmapbutton.h_
Enable() is sort of a generic way to grey things out in dialogs.

-ScottA

On 26/05/2013 at 08:59, xxxxxxxx wrote:

ToolData plugins have in contrast to ToolDescriptionData plugins a GeDialog attached to it. 
I am accessing the dialog attached to the tool. Check the example code. The code itself is 
from a CommandData plugin.

I am aware about the nature of bfm_disable. I have posted it just as a demonstration 
that the general approach works and that i can alter the gadget attached to id that way.
I am only missing the correct id(s).

On 26/05/2013 at 11:58, xxxxxxxx wrote:

hey,

for the record and others who might search on this, i made it just to complicated. I thought
BitmapButton is not wrapped for python but it actually is. So you can keep it pretty straight 
forward.

    # --- Toggle the freeze state and toggle the freeze button of the active fhBaseToolData
    # -----------------------------------------------------------------------------------------------
    def Execute(self, doc) :
        tool = plugins.FindPlugin(doc.GetAction(), c4d.PLUGINTYPE_TOOL)
        if (isinstance(tool, plugins.BasePlugin) and
            isinstance(tool.GetNodeData(), fhBaseToolData.fhBaseToolData) and
            isinstance(tool.GetNodeData().Dialog, fhBaseToolDialog.fhBaseToolDialog) and
            tool.GetNodeData().Dialog.CanFreeze) :
            btn = tool.GetNodeData().Dialog.FindCustomGui(id       = fhPolyTools.IDC_BASE_FREEZE_BTN, 
                                                          pluginid = c4d.CUSTOMGUI_BITMAPBUTTON)
            if isinstance(btn, c4d.gui.BitmapButtonCustomGui) :
                fhPolyTools.ID_ISFROZEN = not fhPolyTools.ID_ISFROZEN
                btn.SetToggleState(fhPolyTools.ID_ISFROZEN)
        c4d.SpecialEventAdd(messageid = fhPolyTools.PID_FHFREEZETOOL)
        return True