Confusing ToolData content



  • @c4ds said in Confusing ToolData content:

    Couldn't find anything related to a Description Manual

    Hello,

    there is a Description Manual.

    best wishes,
    Sebastian



  • Regarding the embedded description GUI, I was just thinking loudly. I understand your design decision completely.
    And actually I didn't want to imply, you should store the Descriptions (after all these contain no values). I thought more of a combination of the GetParameter() approach (where you were lacking the information, which parameters exist) and the description code I suggested. So you could during your initialization (in your case probably, when the user drags a new tool onto the wheel) find out about all available parameters and with this prepare a BaseContainer to store whatever you need later on.

    Cheers,
    Andreas



  • In the meantime I am able to parse the Descriptions and iterate over the available entries and perform a GetParameter.
    A NodeData derived object can implement GetDEnabling to indicate if an element is to be set enabled or disabled. How would one go about retrieving this state from the Description elements?
    And what about the DESC_HIDE flag, is that accessible as well somewhere?

    I understand the Description Manual is meant for the regular way of using the descriptions (in a NodeData derived plugin), so obviously I will not find answers there related to my extreme use-case.



  • Hello,

    The information if a parameter is enabled is not stored in the Description object. You can use C4DAtom::GetEnabling() to check if the parameter is enabled (see C4DAtom Manual).

    DESC_HIDE is stored in the Description object as usual. See Description Settings Manual.

    Best wishes,
    Sebastian



  • Thanks for the links Sebastian.
    Had read these before, but still cannot figure out how to process the DESC_HIDE. I simply don't get it.

    I am trying with a Python script, as this is faster to prototype.

    import c4d
    
    def main():
        toolID = 431000015 # Bevel (id obtained from script log)
        
        tool = c4d.plugins.FindPlugin(toolID, c4d.PLUGINTYPE_TOOL)
        print "Tool = %s (%i)" % (tool.GetName(), toolID)
    
        # parse the description
        desc = tool.GetDescription(c4d.DESCFLAGS_DESC_0)
        for bc, paramid, groupid in desc:
            elementID = paramid[0].id
            
            # for testing purposes we are only interested in the "Apply" button
            if elementID != c4d.MDATA_APPLY:
                continue
            
            print bc[c4d.DESC_NAME], paramid, groupid
            print "Hidden = ", bc[c4d.DESC_HIDE]
    
    if __name__=='__main__':
        main()
    

    With the above I do get None as result for the DESC_HIDE.
    It might be explained in the manuals, I just don't get it. Sorry!



  • Hello,

    not every parameter description stores a value for DESC_HIDE. Typically a component only sets the value if it wants to hide a specific parameter.

    So depending on how to access the value, the access might fail. E.g.

    GeData data = bc->GetData(DESC_HIDE);
    
    if (data.GetType() == DA_LONG)
    {
      const Bool hide = data.GetBool();
      ApplicationOutput("DESC_HIDE: @", hide);
    }
    else
    {
      ApplicationOutput("DESC_HIDE not set"_s);
    }
    

    cannot read DESC_HIDE if the value is not stored in the BaseContainer.

    You can access BaseContainer values using functions like GetBool(). Such a function allows you to define a default value that is returned if no value is stored in the BaseContainer:

    const Bool hideStatus = bc->GetBool(DESC_HIDE, false);
    ApplicationOutput("DESC_HIDE status: @", hideStatus);
    

    See BaseContainer Manual and GeData Manual.

    Best wishes,
    Sebastian



  • I do get all you are trying to explain. It all makes sense ... it does.
    Still, I am unable to read out the attribute information I am looking for.

    import c4d
    
    def main():
        # get the current active tool
        toolID = doc.GetAction()
        tool = c4d.plugins.FindPlugin(toolID, c4d.PLUGINTYPE_TOOL)
        print "Tool = %s (%i)" % (tool.GetName(), toolID)
    
        # parse the description
        desc = tool.GetDescription(c4d.DESCFLAGS_DESC_0)
        for bc, paramid, groupid in desc:
            elementID = paramid[0].id
            
            # for testing purposes we are only interested in the "Apply" button
            if elementID != c4d.MDATA_APPLY:
                continue
            
            # the Bevel tool has the "Apply" button visible (sometimes disabled, but visible)
            # the Live Selection tool has the "Apply" button part of its description,
            # but this button is not visible, it should thus have its DESC_HIDE set to true ???
            
            # Select the bevel tool and execute this script => "No DESC_HIDE"
            # Select the live selection tool and execute this script => "No DESC_HIDE" !!!
            
            # >>> How to get the Live Selection's hidden state of MDATA_APPLY ???
                       
            gd = bc.GetData(c4d.DESC_HIDE)
            if gd == None:
                print "No DESC_HIDE"
            elif bc.GetType(c4d.DESC_HIDE) == c4d.D_LONG:
                print "DESC_HIDE = ", bc.GetBool(c4d.DESC_HIDE, False)
            else:
                print "DESC_HIDE not LONG"
    
    
    if __name__=='__main__':
        main()
    
    


  • Hello,

    the descriptions are based on description resource files (see Parameter Description Resources). In toolbase.res you see that MDATA_APPLY is part of the group MDATA_COMMANDGROUP:

    GROUP MDATA_COMMANDGROUP
    {
      DEFAULT 1;
      GROUP
      {
        BOOL MDATA_INTERACTIVE { }
    
        GROUP
        {
          COLUMNS 3;
          DEFAULT 1;
    
          BUTTON MDATA_APPLY { FIT_H; }
          BUTTON MDATA_NEWTRANSFORM { FIT_H; }
          BUTTON MDATA_DEFAULTVALUES { FIT_H; }
        }
      }
    }
    

    In the live selection's resource file toolliveselection.res you see that the base is included but the MDATA_COMMANDGROUP group is hidden:

    INCLUDE ToolBase;
    
    ...
    
    HIDE MDATA_COMMANDGROUP;
    

    Therefore, MDATA_APPLY has no DESC_HIDE setting. The whole group is hidden using DESC_HIDE.

    Inside Cinema this is checked like this:

    BaseContainer *groupData = desc->GetParameterI(MDATA_COMMANDGROUP, nullptr);
    if (groupData != nullptr && groupData->GetBool(DESC_HIDE))
      return true;
    
    BaseContainer *applyData = desc->GetParameterI(MDATA_APPLY, nullptr);
    if (applyData != nullptr && applyData->GetBool(DESC_HIDE))
      return true;
    

    best wishes,
    Sebastian



  • @s_bach said in Confusing ToolData content:

    The whole group is hidden using DESC_HIDE.

    Ah ... didn't even consider that one.
    This makes perfect sense.

    Thanks for going through all the trouble of explaining.



  • Congrats on the new forum! it is very informative
    About time