doc.AddUndo with Selection



  • 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



  • 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?



  • 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 ? :/



  • 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 ?



  • 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*



  • 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.



  • 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


Log in to reply