[Issue] Undo doesn't remove UserText attributes

Unless of course that’s intentional. :smiley:

I’d like to understand the why.

Investigating further, might be a false alarm.

Nope, confirmed.
Applying UserText attributes with python then undo doesn’t remove them.

Hi @ivelin.peychev,

there is an open item for it which is unfortunately sheduled for 7.0. If you really need this, you can setup a custom undo/redo event to make it work, but be aware that messing around with such events is not easy nor recommended.

_
c.

1 Like

Thanks for letting me know @clement
Truth is I have too much to learn with Python.
And I am in a prototyping stage so it is not fatal. I don’t save my files. It was just very weird when I found this bug.

The fact that it is scheduled for Rhino7 is troublesome. This is not a new Rhino7 function. This is clearly a bug. As such it has to be fixed in Rhino6 release lifetime.

@ivelin.peychev, the bug exists since RH5, so i had to find various workarounds. An easy one is to select the object(s) and script the _SetUserText command.

import rhinoscriptsyntax as rs

def DoSomething():
    
    obj_id = rs.GetObject("Select curve", 4, True, True)
    if not obj_id: return
    
    key = chr(34) + "Hello" + chr(34)
    val = chr(34) + "World" + chr(34)
    
    cmd = "_-SetUserText _AttachTo=_Attributes {} {}".format(key, val)
    rs.Command(cmd, False)
    
DoSomething()

_
c.

2 Likes

This is great - this will be very helpful for my ScaleModel tool, so I know what scale I am working at even after undos.
Thanks!

Great, thanks for sharing it @clement

Very disappointing. I bought my Rhino5 license a few months before Rhino6 release. I decided to buy Rhino6 and didn’t play a lot with Rhino5. I knew UserText attributes goes back but to have this issue exist since then. This isn’t nice. If it could be solved with a single script how difficult could it be to get in one of the next SRs @pascal?

Ahh do you have a workaround for Document user text? This technique works for setting the document user text but I cannot undo.
Preferably Rhino 5

make a button with this script:

import rhinoscriptsyntax as rs



rs.Command("_undo")
objs = [obj for obj in rs.AllObjects()]
for obj in objs:
    usertext = rs.GetUserText(obj)
    for ut in usertext:
        rs.SetUserText(obj,ut,"")

:stuck_out_tongue:

or some modification cuz this will delete all usertext attributes on all objects :crazy_face:

ermm… I want to revert to the previously stored DocumentUserText when my users hit the undo button.
My script asks for a new model scale, rescales the model and then stores the new model scale. Undoing reverts the model to the previous scale value but keeps the most recently entered scale in the DocumentUserText :frowning:

@clement previously gave me this solution under a different username (I forgot I had that account!)

Looks like I need to be brave and implement that one, better late than never

1 Like

:smiley: We have a moral story about this in Bulgaria.

    • Nevolya, rough translation into English = Will Power, but they apparently didn’t know and they thought it’s a person. :smiley:

What if upon start of the script it stores the current value of the scale in sticky, use my script above to get the value out of the sticky and put it on the objects you’ve selected to scale along with the actual Undo command?

Mitch actually describes pretty much my idea.
Another option would be to cpickle the value

When I get a round tuit

1 Like

I don’t get it. I’m sorry :slight_smile:. Could you elaborate?

image

2 Likes

Оh, I get it. English version of the Bulgarian “Nevolya” (Неволя)

1 Like

Sample now stored here, with added scary warnings

1 Like