Maxon Developers Maxon Developers
    • Documentation
      • Cinema 4D Python API
      • Cinema 4D C++ API
      • Cineware 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

    doc.AddUndo with Selection

    PYTHON Development
    0
    7
    1.1k
    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
      Helper
      last edited by

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

      On 27/04/2011 at 05:57, xxxxxxxx wrote:

      Hi.

      I'm having trouble with doc.AddUndo(c4d.UNDOTYPE_CHANGE_SELECTION,op).
      After executing the code, c4d jumps 2 Steps backwards, and not 1, clicking on Undo.

                  original    = op.GetPointS()  
                doc.AddUndo(c4d.UNDOTYPE_CHANGE_SELECTION,op)  
                point_sel.CopyTo(original)
      

      Any Idea ?

      Cheers, nux

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

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

        On 27/04/2011 at 12:38, xxxxxxxx wrote:

        Can you please post more lines or an example which reproduces this behave?

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

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

          On 27/04/2011 at 17:51, xxxxxxxx wrote:

          Of course, sorry.

            
          import c4d  
            
            
          sel = c4d.BaseSelect()  
          doc.AddUndo(c4d.UNDOTYPE_CHANGE_SELECTION,op)  
          sel.CopyTo(op.GetPolygonS())  
            
          c4d.EventAdd()
          

          1. Create a Polygonobject.
          2. Select some Polys
          3. Again select some other Polys
          4. Execute the script
          5. Do undo

          And you'll see the first polygon selection, not the second you've done. 😠

          Cheers, nux

          //edit:
          I think I could figure out the issue, let me just try that.
          (Start/EndUndo missing)

          Hm, this code works:

            
          import c4d  
            
            
          sel = c4d.BaseSelect()  
          doc.StartUndo()  
          doc.AddUndo(c4d.UNDOTYPE_CHANGE_SELECTION,op)  
          sel.CopyTo(op.GetPolygonS())  
          doc.EndUndo()  
            
          c4d.EventAdd()
          

          But i just don't get it to work in my plugin.
          In this case it just copys a selection to the corresponding selection for the mode.

                  doc.StartUndo()  
                if mode     == c4d.Mpoints:  
                    doc.AddUndo(c4d.UNDOTYPE_CHANGE_SELECTION,op)  
                    point_sel.CopyTo(op.GetPointS())  
                elif mode   == c4d.Mpolygons:  
                    doc.AddUndo(c4d.UNDOTYPE_CHANGE_SELECTION,op)  
                    poly_sel.CopyTo(op.GetPolygonS())  
                elif mode   == c4d.Medges:  
                    point_sel_cache     = op.GetPointS().GetClone()     #Save the current pointselection  
                    doc.AddUndo(c4d.UNDOTYPE_CHANGE_SELECTION,op)  
                    point_sel.CopyTo(op.GetPointS())                    #Copy Pointselection to Object  
            
                    bc      = c4d.BaseContainer()                       #BaseContainer holding Data for MC  
                    bc[c4d.MDATA_CONVERTSELECTION_LEFT]     = 0         #Convert Points  
                    bc[c4d.MDATA_CONVERTSELECTION_RIGHT]    = 1         #to Edges  
                    bc[c4d.MDATA_CONVERTSELECTION_TOLERANT] = False     #Tolerance gives wrong results  
                    bc[c4d.SELECTION_NEW]                   = True  
            
                    doc.AddUndo(c4d.UNDOTYPE_CHANGE_SELECTION,op)  
                    SendModelingCommand(        command     = c4d.MCOMMAND_CONVERTSELECTION,  
                                                list        = [op],  
                                                doc         = op.GetDocument(),  
                                                bc          = bc  
                                        )  
            
                    doc.AddUndo(c4d.UNDOTYPE_CHANGE_SELECTION,op)  
                    point_sel_cache.CopyTo(op.GetPointS())              #Restore Pointselection Cache  
            
                doc.EndUndo()
          

          What undo-stuff did i miss here ? 😕

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

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

            On 29/04/2011 at 09:02, xxxxxxxx wrote:

            Any idea ?

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

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

              On 01/05/2011 at 23:45, xxxxxxxx wrote:

              *push*

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

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

                On 04/05/2011 at 05:06, xxxxxxxx wrote:

                The code seems to be fine. I can't explain the behave yet.

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

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

                  On 05/05/2011 at 04:59, xxxxxxxx wrote:

                  Would be nice if you could find a solution.
                  Thanks in advance,
                  Niklas

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