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
    • Recent
    • Tags
    • Users
    • Login

    How to prevent C4D automatically undo handling?

    Scheduled Pinned Locked Moved PYTHON Development
    4 Posts 0 Posters 386 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

      On 18/07/2013 at 05:02, xxxxxxxx wrote:

      Hi guys,

      i dont want to allowed undos for my object plugin, but C4D handles undos for parameter changes in the attributes manager of an object automatically ( _MSG_DESCRIPTION_INITUNDO_ ). Im searching for a way to prevent this for days, but i can`t get it.

      Please, can somebody tell me it is possible or not?
      Or is there a way to get the undo list of C4D to remove the undo entries of my object?

      Thank you very much for any advices!

      shirayuki


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

        On 18/07/2013 at 05:08, xxxxxxxx wrote:

        I know it's not a answer to your question, but why on earth would you want to break CINEMA 4D's undo system for your object?

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

          On 18/07/2013 at 08:51, xxxxxxxx wrote:

          Hi Jack,

          this is a good question ^^ and a little bit difficult to explain.
          Overall...
          first i dont need undo for this object, because the plugin is just use in a controller xref. Second i cant implemented undo the right way, so its better not to do it.
          But now its not as simple as it seemed to me before.

          Maybe your are able to give me some advices to add undo correctly in my plugin 🙂

          My object data plugin translates and rotates polygon objects like a null group.
          So i dont have to change the object axis and do it separately. Why i have to develop a plugin for this simple functions? Because of the defined scene structure, im not allowed to arrange this polygon objects in a null group together or rearrange the scene structure.
          _
          Some example code:

          _ class Transformator(plugins.ObjectData) :
                #...

          def Message(self, op, type, data) :
               #...    
               elif type==c4d.MSG_DESCRIPTION_CHECKUPDATE:    
                   self.main(op)

          def main(self,op)
                #...
                self.transformObjs(op,objList,rotVec,posVec)

          def transformObjs(self,op,objList,rotVec,posVec) :
                '''
                    op: my objectdata plugin
                    objList: polygon objects to be tansformed (linked in InExcludeList)
                    rotVec: rotation vector
                    posVec: position vector
                '''
                doc = op.GetDocument()
                doc.StartUndo()
                doc.AddUndo(c4d.UNDO_CHANGE,op)
               
                parentList = []
                for obj in objList:
                    doc.AddUndo(c4d.UNDO_CHANGE,obj)
                    #store parent for arranging back later
                    parentList.append(obj.GetUp())
                    objMg = obj.GetMg()
                    #arrange polygon objects under my object plugin
                    obj.InsertUnder(op)
                    obj.SetMg(objMg)
                    obj.Message(c4d.MSG_CHANGE) #i'm not sure this is nessesary
               
                #transformed
                op.SetAbsRot(rotVec)
                op.SetAbsPos(posVec)
               
                #arrange back to primary scene structure
                for i,obj in enumerate(objList) : 
                    doc.AddUndo(c4d.UNDO_CHANGE,obj)
                    objMgRot = obj.GetMg()
                    obj.InsertUnder(parentList _) _
           _            obj.SetMg(objMgRot)
                    obj.Message(c4d.MSG_CHANGE)
                   
                doc.EndUndo()             
                       #...
           
          By this way, too many undos are created (every single value changed)
          like in this post: https://developers.maxon.net/forum/topic/6978/7859_undo-in-plugin&KW=self.mouse_checker&PID=32593#32593

          But is actual not the main issues.

          The probleme is that i can`t set the polygon object and the controller object (my object plugin) back on the same undo step.
          So it is not user friendly and they can make unknown mistakes very easily.

          I hope, you can understand me by my bad english skills 😉

          Thanks for any tips!

          shirayuki

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

            On 18/07/2013 at 09:36, xxxxxxxx wrote:

            You are not supposed to add undos in expressions. Just leave it as it is. Though you have to ensure

            that for a specific set of parameters and circumstances, your expression must deliver the exact
            same results.

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