Escape characters in doc.Strings


I ran into an issue where I could not purge some usertext entries with python rhinoscript
specifically these type of entries:

In the method GetDocumentUserText pointed to the cause, apparently there was a need to filter escape characters for reasons unknown to me:

    #todo: leaky abstraction: "\\" logic should be inside doc.Strings implementation
    keys = [scriptcontext.doc.Strings.GetKey(i) for i in range(scriptcontext.doc.Strings.Count) if not "\\" in scriptcontext.doc.Strings.GetKey(i)]

I’d like to purge the document form all userdata and want do it like so:

import rhinoscriptsyntax as rs
import scriptcontext as sc

keys = [sc.doc.Strings.GetKey(i) for i in range(sc.doc.Strings.Count)]
for key in keys:

It clears all entries including those with the escape-characters.
However given the comment in the python method, I’d like to know if and what danger there lies in not filtering out keys with escape characters.


I’m looking at this a bit more. Brb

As far as I can tell there may have been a time where rs.SetDocumentUserText didn’t accept escape characters but I can’t see a good reason for applying the filter now.
Logged here

1 Like

Hi Alain,

Thanks for digging around.
Really appreciate the quick response.