Update page view after changes of a text field


i’m using document text fields in an annotation text object, which are changed programmatically.
(see http://docs.mcneel.com/rhino/5/help/en-us/information/text_fields.htm)

After i changed the document texts i need to update the page view to see the changes.
I tried the Redraw(); method of the page view and of the document, but nothing happens.

What method do i need to call to update the page view and the text objects?


Hi Wolfgang,

Your finding all issues, aren’t you? :wink:

To fix this, you going to need to call a function whose declaration is not in the SDK.

Add the following line of code to your project’s StdAfx.h file:


// Rhino Plug-in
#include "C:\Program Files (x86)\Rhino 5.0 x64 SDK\Inc\RhinoSdk.h"

// Render Development Kit.
#include "C:\Program Files (x86)\Rhino 5.0 x64 SDK\Inc\RhRdkHeaders.h"

// Updates a serial number that text fields use to determine
// if they need to reparse on their next paint
void RhUpdateTextFieldSerialNumber();


Then in your source code, do something like this:

if (context.m_doc.SetUserString(key, string_value))

Does this help?

Hi Dale,

well, indeed, there were some issues these days :fearful:

So i tried it out and it works like a charm.

I must say, the support from you and your company is far the best and we are working with a lot of CAD software. We really appreciate your work! Thanks! :thumbsup:


Sorry to revive an old thread…
I’m changing custom Usertext with a python script and I’m running into what I believe to be the same problem, how could it be solved there?
More specifically I would like GH to ‘realize’ something was changed in the Document with the script and to then update the referenced objects. At the moment it only works when I manually change a value in the usertext and hit enter, not when I do it with code.


Hi @thomas.jeremy.tait,

We’re not going to be able to help without something (a 3dm file, a gh file, some code we can run) that allows us to repeat the problem you are having.


– Dale

Hi Dale,

Sorry for being unclear.
I’m using a Grasshopper Script that uses Elefront’s ReferencebyName component to watch for changes in the Rhino document and update the referenced objects if changes are detected.
With the script below I am making a change to the usertext of an object that has the Name that the GH component should be ‘watching’. However although the usertext is successfully changed with the Python Script, it doesn’t lead to an update in GH. Only when I manually hit ‘Update’ on the Elefront component, the changes in usertext are recognized.

As a workaround I tried to simply move the object up and down back to the same place, and when I do that, the component in GH actually recognizes something was changed, and it also reads the new usertext.
I was wondering if there is a way to do it without this workaround.

    filter = Rhino.DocObjects.ObjectType.Hatch 
        rc, objrefs = Rhino.Input.RhinoGet.GetMultipleObjects("Select Objects:", False, filter)
        if rc != Rhino.Commands.Result.Success: return

    objects = []
    for objref in objrefs:
        object = objref.Object()
        if object:

    for i in range(len(objects)):
         objects[i].Attributes.SetUserString("height", str(dialogBuildingHeight))
         #code until here doesn't update in GH, as a workaround the following works:
         xform1 = Rhino.Geometry.Transform.Translation(0,0,1)    #move up 1m
         xform2 = Rhino.Geometry.Transform.Translation(0,0,-1)   #move back down 1m

         sc.doc.Objects.Transform(objects[i], xform1, True)
         sc.doc.Objects.Transform(objects[i], xform2, True)

Thank you!

Hi @thomas.jeremy.tait,

Instead of doing this:

for i in range(len(objects)):
    objects[i].Attributes.SetUserString("height", str(dialogBuildingHeight))

do this:

for i in range(len(objects)):
    attributes = objects[i].Attributes.Duplicate()
    attributes.SetUserString("height", str(dialogBuildingHeight))
    sc.doc.Objects.ModifyAttributes(objects[i].Id, attributes)

Does this help?

– Dale

Hi @Dale,

Thank you, this does the trick! Just had to add a Boolean at the end.

sc.doc.Objects.ModifyAttributes(objects[i].Id, attributesTmp, True)

Will do some reading on when to use scriptcontext!

Thanks again,