CommandData plugin with a res dialog



  • The CommandData class doesn't have a CreateLayout method.
    So, how can I load a description res file to show in the Attribute Manager, when I call the plugin from the Plugins menu?



  • In Short: You can't.
    Long story:
    Afaik CommandData plugins don't have an interface per se. They are literally just commands.
    But there are several ways to get around that.
    You need at least a NodeData plugin or anything that derives from that. (a scene hook for example), or even a dummy object, or a tool.

    Another option would be to call a Dialog (Dialogs don't have descriptions, but layouts - you can load it with a DescriptionCustomGui however.)

    May I ask what exactly you want to do, so we can point you in the right direction?



  • I just want to create a plugin that, when executed from the Plugin menu would show a few parameters in the Attribute Manager.
    One of the gizmos would be a button that, when pressed, would execute the code, using the data in the parameters.
    I know how to do all that for tag and object plugins.
    Would I have to create a Tool plugin for that?



  • @rui_mac Sounds like you need a GeDialog with a CommandData.



  • But, will it appear in the Attribute Manager? Or in a floating dialog?



  • In C++ I create a Tool plugin and it shows the parameters in the Attribute Manager, just the way I want it.
    Isn't it easy to do the same in python?



  • You can use a Tool plugin, of course. However, it seems a bit weird.
    I would go for a NodeData or ObjectData plugin as this would be the bare minimum and also does not show up in the recent tools list.
    The downside with NodeData plugins is, that by default, the do not belong to the document. That can be an advantage or disadvantage, depending on what your plugin should do.


  • Global Moderator

    Hello,

    as others have already pointed out, the typical way of presenting arbitrary functions to a user is to use a CommandData plugin that hosts and shows a floating GeDialog. Such a dialog can present any kind of information or interaction. If you want to, you can add this dialog to your layout as well.

    As an example: You can open the "Character" -> "Manager" -> "Weight Manager". This dialog presents various gizmos including buttons to press. There is nothing wrong about that. Why do you think you need to present that in the Attribute Manager?

    The Attribute Manger is used to present parameters of elements associated with the current document e.g. objects or tags or the specific settings of a tool stored within the document. The Attribute Manager is not an arbitrary canvas.

    An example for a CommandData / GeDialog combination in Python is Py-MemoryViewer.pyp.
    An example for a Python tool is Py-LiquidPainter.pyp.

    best wishes,
    Sebastian



  • This plugin is a add-on to a set of plugins and all of them show stuff in the Attribute Manager.
    One of them is a tag, another is a tool, another is a shader, etc...
    It was just to keep a consistency.



  • But, assuming that I would go with the dialog way, do I need to create it in code, or can I load it from a res file?


  • Global Moderator

    Hello,

    yes, you can use resource files to define the dialog layout. Or combine layout files and code.

    def CreateLayout(self):
    
      self.SetTitle("Dialog Test")
    
      # load dialog from resource file
      if self.LoadDialogResource(10000, None, 0) == False:
        return False
    
      # set a different title
      self.SetTitle("New Title")
    
      # disable a GUI element
      self.Enable(10001, False)
    
      return True
    

    See GeDialog Manual and Layout files.

    best wishes,
    Sebastian