Can Python write to Rhino's notes?

Is there a Python method for writing to Rhino’s notes?

Thanks,

Dan

You can get there via scriptcontext…

import scriptcontext as sc
notes=rs.GetString("Enter your notes here")
sc.doc.Notes=notes

–Mitch

Thanks Mitch.

I’m sure you’ve already figured this out, but for the benefit of anyone else listening in, the above replaces whatever you currently have in Notes, so if anything was already in there it will be lost. So, for security’s sake - unless you really want to replace any pre-existing content - you can grab any existing notes first with the same function then replace the notes with the existing + new…

import scriptcontext as sc
import rhinoscriptsyntax as rs
add_notes = "This is what I am adding to my notes"
curr_notes = sc.doc.Notes
sc.doc.Notes = curr_notes + add_notes

If there are no existing notes, sc.doc.Notes returns an empty string, so it works anyway.

You may want to use some more formatting, line breaks etc. - all the usual python string stuff applies.

–Mitch

Again, thanks Mitch. Very useful information.

Dan

Cool, thanks.

Could we also, using your example variables, print this out to a text string using rs.AddText as well (in addition to)?
«Randy

Sure, it’s a string like any other. And I think Mac can now finally write multiline text, so all should work fine… --Mitch