Undo question

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

On 19/02/2006 at 11:40, xxxxxxxx wrote:

User Information:
Cinema 4D Version:   9.0+ 
Platform:   Windows  ; Mac  ;  Mac OSX  ; 
Language(s) :     C++  ;

---------
Howdy,

Here's the problem:
From a CommandData plugin, I'm adding 3 tags to the document and making one of them the active tag. This is all being done between a StartUndo()/EndUndo() call, but setting the tag as the active tag is not being logged into the undo group, and it takes two undos to undo the command.

  
doc->StartUndo();  
  
//...allocate and add tagA code here  
doc->AddUndo(UNDO_NEW,tagA);  
  
//...allocate and add tagB code here  
doc->AddUndo(UNDO_NEW,tagB);  
  
//...allocate and add tagC code here  
doc->AddUndo(UNDO_NEW,tagC);  
  
doc->SetActiveTag(tagB);  
  
doc->EndUndo();  

I see there is an UNDO_ACTIVATE flag, but the SDK documentation says this:
**UNDO_ACTIVATE

Automatically managed by SetActiveObject()/Tag()/Material() etc. No need to use manually.**

But it doesn't seem to add it to the undo group.
I did try adding the line:

    doc->AddUndo(UNDO_ACTIVATE, tagB);

...both before and after the SetActiveTag() call, but neither one had an effect, and it still takes two undos to undo the command.

Any ideas?

Adios,
Cactus Dan

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

On 20/02/2006 at 04:32, xxxxxxxx wrote:

Perhaps it makes a difference if you reverse the order to:

  
.. create tagB  
doc->SetActiveTag(tagB)  
doc->AddUndo(UNDO_NEW,tagB)  

you could also try to set the active bit manually.

  
.. create tagB  
doc->AddUndo(UNDO_NEW,tagB)  
  
doc->AddUndo(UNDO_ACTIVEATE,tagB);  
tagB->SetBit(ACTIVE_BIT);  

i think this will most likely work. As well as this:

  
.. create tagB  
tagB->SetBit(ACTIVE_BIT);  
doc->AddUndo(UNDO_NEW,tagB)  

but then you loose all the convenience of SetActiveTag(). Perhaps you must write your own SetActiveTag which adds all the selection undos to your undo block.

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

On 20/02/2006 at 16:56, xxxxxxxx wrote:

Howdy,

Thanks Michael, for the reply, but I've since discovered that it's something else that's wrong, because if I comment out the line...

  
//doc->SetActiveTag(tagB);  

...it still needs two undos to undo the command. :o(

I'm wondering if there is a problem because the actual program flow is like this:

  
create tagA  
create tagB  
branch to initialize data in tagB  
create tagC  

... I reckon I better put on the debugging hat.

Adios,
Cactus Dan

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

On 20/02/2006 at 17:21, xxxxxxxx wrote:

Howdy,

AHA!

I found the problem. It seems that you can't have a StartUndo()/EndUndo() nested within a StartUndo()/EndUndo(). The problem is that after adding tagC, I'm sending a MSG_DESCRIPTION_COMMAND to tagC to simulate the pressing of a button, but within that button's routine in tagC, there is another StartUndo()/EndUndo() group. If I don't send the message, then undoing the command works fine with only one undo.

I reckon I'll have to add a separate routine to handle invoking that button from the command tool. ;o)

Adios,
Cactus Dan