[Issue] Undo doesn't remove UserText attributes

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

Unfortunately, I feel that even this won’t work if you set the usertext attributes by a python script. That has to happen from McNeel when they fix the bug.

@ivelin.peychev, i can confirm it works in V5 as i used it to undo certain things…

_
c.

1 Like

YESSS it finally works :smiley: :smiley: :smiley:

1 Like

A bit strange that this is scheduled for 7. Seems like this has been brought up a few times, including in a topic from 5 years ago.

1 Like