[Issue] Undo doesn't remove UserText attributes


(IVELIN PEYCHEV) #1

Unless of course that’s intentional. :smiley:

I’d like to understand the why.


(IVELIN PEYCHEV) #2

Investigating further, might be a false alarm.


(IVELIN PEYCHEV) #3

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


#4

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.


(IVELIN PEYCHEV) #5

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.


#6

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


(Graham) #7

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!


(IVELIN PEYCHEV) #8

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?


(Graham) #10

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


(IVELIN PEYCHEV) #11

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:


(Graham) #12

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:


(Graham) #13

@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


(IVELIN PEYCHEV) #14

: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:

(IVELIN PEYCHEV) #15

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?


(IVELIN PEYCHEV) #16

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


(Graham) #17

When I get a round tuit


(IVELIN PEYCHEV) #18

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


#19

image


(IVELIN PEYCHEV) #20

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


(Graham) #21

Sample now stored here, with added scary warnings