Quantcast
Channel: Scripting - McNeel Forum
Viewing all articles
Browse latest Browse all 5897

Layers, layer names and undo stack

$
0
0

@Helvetosaur wrote:

I am having trouble with understanding how the undo stack is working with layers. I am seeing a couple of odd phenomena here following is a small example... Run the following script with the posted files (one has all top level layers, the other has some sublayers). What it does is "randomize" all the top level layer names, and then restore them back to their original names via a lookup table (why I am doing this I will explain later, the code is part of a larger project).

The script actually executes fine and does what it is supposed to (to see, set a breakpoint at the pass in the main def), the problem happens if you hit the Undo button after running the script. You cannot get back to the original file state, it will undo the restoration of the names from random, but not the randomization in the first place. So the file is left with random layer names.

I don't know if this is inevitable due to how layers are dealt with in the Undo stack or if something can be done to make this work better... I actually thought of clearing the undo stack at the end of the script, but that would not be very nice.... :stuck_out_tongue_winking_eye:

Thx, --Mitch

LayerRandomizeRestoreUndo.py (933 Bytes)

LayerEx1.3dm (24.9 KB)

LayerEx2.3dm (25.4 KB)

Posts: 2

Participants: 2

Read full topic


Viewing all articles
Browse latest Browse all 5897

Trending Articles