Maxon Developers Maxon Developers
    • Documentation
      • Cinema 4D Python API
      • Cinema 4D C++ API
      • Cineware API
      • ZBrush Python API
      • ZBrush GoZ API
      • Code Examples on Github
    • Forum
    • Downloads
    • Support
      • Support Procedures
      • Registered Developer Program
      • Plugin IDs
      • Contact Us
    • Categories
      • Overview
      • News & Information
      • Cinema 4D SDK Support
      • Cineware SDK Support
      • ZBrush 4D SDK Support
      • Bugs
      • General Talk
    • Unread
    • Recent
    • Tags
    • Users
    • Login

    ObjectData: GeDiaglog Updating in CinemaLayout

    Scheduled Pinned Locked Moved PYTHON Development
    5 Posts 0 Posters 514 Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • H Offline
      Helper
      last edited by

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

      On 26/04/2012 at 04:57, xxxxxxxx wrote:

      Hello everybody,

      some days ago I started paying attention to plugin-writing. After several attempts, where I've struggled with the basic structure, I'm trying now for quite some time to bring a test project about that I thought it was quite easy.
      I want to create an information box in which the currently active object is always displayed. I began to try on CommandData and GeDialog, but unfortunately I didn't manage to update the dialog when the active object is changing. I've done it with ObjectData. Unfortunately, the update will only work as long as the dialog is in a window. If I integrate it into the layout of cinema, all the commands are executed correctly in the background (I´ve tried with 'print'), but the dialog isn't updated anymore. I think the cinemalayout itself has to be updated, because it works when I minimize cinema and then turn back to full-screen. How can I do that?
      I work with R12, window7/64bit.

      I hope anyone can help...
      greetings
      rown

      import os  
      import math  
      import sys  
      import c4d  
        
      from c4d import plugins, utils, bitmaps, gui  
        
      # be sure to use a unique ID obtained from www.plugincafe.com  
      PLUGIN_ID = 1000001 # TestID only!!!!!!!!!!!  
        
      GR_T        = 10001  
      TOBJ        = 10002  
      OBJ         = 10003  
      BOOL        = 10050  
        
        
      # MyDialog class  
      class MyDialog(gui.GeDialog) :  
        
        name = "-"  
        
        def CreateLayout(self) :  
            self.SetTitle("rownTEST02")  
        
            self.GroupBegin(id=GR_T, flags=c4d.BFH_LEFT, cols=2)  
            self.GroupBorderSpace(10, 10, 10, 10)  
            self.AddStaticText(id=TOBJ, flags=c4d.BFH_LEFT, initw=133, inith=10, name="Active Object", borderstyle=c4d.BORDER_NONE)  
            self.AddStaticText(id=OBJ, flags=c4d.BFH_LEFT, initw=400, inith=10, name=self.name, borderstyle=c4d.BORDER_THIN_IN)  
            self.AddCheckbox(id=BOOL, flags=c4d.BFH_LEFT, initw=120, inith=10, name="")  
            self.GroupEnd()  
            return True  
          
        def InitValues(self) :  
            self.IsActiveObj()  
            self.SetString(OBJ, self.name)  
            return True  
          
        def Command(self, id, msg) :  
            return True  
        
        def IsActiveObj(self) :  
            obj = c4d.documents.GetActiveDocument().GetActiveObject()  
            if obj is None: self.name = "-"  
            else: self.name = obj.GetName()  
        
      class rownTEST02(plugins.ObjectData) :  
        
        dialog = None  
        
        def GetVirtualObjects(self, op, hierarchyhelp) :  
            dirty = op.CheckCache(hierarchyhelp) or op.IsDirty(c4d.DIRTY_DATA)  
            if dirty is False: return op.GetCache(hierarchyhelp)  
        
        def __init__(self) :  
            self.SetOptimizeCache(True)  
        
        def Init(self, node) :  
            return True  
        
        def Message(self, node, type, data) :  
            if type == c4d.MSG_MENUPREPARE:  
                if self.dialog is None:   
                    self.dialog = MyDialog()  
                    self.dialog.Open(dlgtype=c4d.DLG_TYPE_ASYNC, pluginid=PLUGIN_ID, defaultw=0, defaulth=0)  
            elif type == c4d.MSG_GETCUSTOMICON:  
                self.dialog.InitValues()  
            return True   
        
      if __name__ == "__main__":  
        dir, file = os.path.split(__file__)  
        icon = bitmaps.BaseBitmap()  
        icon.InitWith(os.path.join(dir, "res", "icon.tif"))  
        plugins.RegisterObjectPlugin(id=PLUGIN_ID, str="rownTEST02",  
                                    g=rownTEST02,  
                                    description="rownTEST02", icon=icon, info=c4d.OBJECT_GENERATOR)  
      
      1 Reply Last reply Reply Quote 0
      • H Offline
        Helper
        last edited by

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

        On 26/04/2012 at 07:48, xxxxxxxx wrote:

        Hi and welcome here!

        In a CommandData you should be able to receive core messages (especially EVMSG_CHANGE) and update the active object name in your dialog:

        def CoreMessage(self, id, msg) :
            if id==c4d.EVMSG_CHANGE:
                print "EVMSG_CHANGE"
                self.InitValues()
          
            return gui.GeDialog.CoreMessage(self, id, msg)
        

        EVMSG_CHANGE core message is sent whenever a change is made in the scene.

        Trying just to do that in an ObjectData plugin isn't the best place.

        1 Reply Last reply Reply Quote 0
        • H Offline
          Helper
          last edited by

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

          On 26/04/2012 at 13:14, xxxxxxxx wrote:

          Hello Yannick,

          thanks for bidding me welcome. :]
          You're right: Command Data, Core Message and EVMSG_CHANGE are the keywords. With the help of NoPhoto (c4dnetwork) I've found the solution and now it works.
          I wanted to know which messages are sent when, just to see if I can filter better. There are some IDs that I cannot identify (-24523562, 1018484, 1018490, 200000221). Does anyone know what they mean? And are there special IDs for ACTIVE_OBJCET_CHANGED(old coffee) or Point/Polygon-Selection-of-the-active-object-has-been-changed?

          Here the Code:

          import c4d  
          from c4d import bitmaps, gui, plugins  
          import collections, os  
            
          # be sure to use a unique ID obtained from www.plugincafe.com  
          PLUGIN_ID = 10000000 #TestID only!!!!!!!!!!!!  
            
          GR_T        = 10001  
          TOBJ        = 10002  
          OBJ         = 10003  
            
            
          def ActiveObjName() :  
              str = "-"  
              obj = c4d.documents.GetActiveDocument().GetActiveObject()  
              if obj is None: str = "-"  
              else: str = obj.GetName()  
              return str  
            
          # MyDialog class  
          class MyDialog(gui.GeDialog) :  
            
              def CreateLayout(self) :  
                  self.SetTitle("CommandData_Test")  
            
                  self.GroupBegin(id=GR_T, flags=c4d.BFH_LEFT, cols=2)  
                  self.GroupBorderSpace(10, 10, 10, 10)  
                  self.AddStaticText(id=TOBJ, flags=c4d.BFH_LEFT, initw=133, inith=10, name="Active Object", borderstyle=c4d.BORDER_NONE)  
                  self.AddStaticText(id=OBJ, flags=c4d.BFH_LEFT, initw=400, inith=10, name="", borderstyle=c4d.BORDER_THIN_IN)  
                  self.GroupEnd()  
                  return True  
                
              def CoreMessage(self,id,msg) :  
                  if id == c4d.EVMSG_CHANGE:  
                      self.SetString(OBJ, ActiveObjName())  
                  return True  
                
              
          class CommandData_Test(plugins.CommandData) :  
              dialog = None  
            
              def Execute(self, doc) :  
                  if self.dialog is None: self.dialog = MyDialog()  
                  return self.dialog.Open(dlgtype=c4d.DLG_TYPE_ASYNC, pluginid=PLUGIN_ID, defaultw=0, defaulth=0)  
            
              def RestoreLayout(self, sec_ref) :  
                  if self.dialog is None: self.dialog = MyDialog()  
                  return self.dialog.Restore(pluginid=PLUGIN_ID, secret=sec_ref)  
            
            
          if __name__ == "__main__":  
               bmp = bitmaps.BaseBitmap()  
               dir, f = os.path.split(__file__)  
               fn = os.path.join(dir, "res", "icon.tif")  
               bmp.InitWith(fn)  
               plugins.RegisterCommandPlugin(id=PLUGIN_ID,   
                                            str="CommandData_Test",  
                                            info=0,  
                                            help="CommandData_Test",   
                                            dat=CommandData_Test(),  
                                            icon=bmp)
          
          1 Reply Last reply Reply Quote 0
          • H Offline
            Helper
            last edited by

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

            On 26/04/2012 at 23:52, xxxxxxxx wrote:

            EVMSG_CHANGE is the best message id to get notified when something has changed in the scene.
            Be careful to filter only message id you really know because core messages can be sent by 3rd party plugins and can be private too.
            GeDialog.CoreMessage() id parameter wasn't documented. This will be fixed in the next update of the docs.

            1 Reply Last reply Reply Quote 0
            • H Offline
              Helper
              last edited by

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

              On 27/04/2012 at 04:23, xxxxxxxx wrote:

              Ok... I´ll filter in this way.

                  def CoreMessage(self,id,msg) :        
                    if id == c4d.EVMSG_CHANGE:  
                        if self.name != self.ActiveObjName() :  
                            self.name = self.ActiveObjName()  
                            self.SetString(OBJ, self.name)  
                            print "change"  
                    return True  
                
                def ActiveObjName(self) :  
                    self.obj = c4d.documents.GetActiveDocument().GetActiveObject()  
                    if self.obj is None: str_ = "-"  
                    else: str_ = self.obj.GetName()  
                    return str_
              

              till the next time and thanks a lot for comments,
              rown

              1 Reply Last reply Reply Quote 0
              • First post
                Last post