Grasshopper requires manual refresh to see User Text Attribute changes

I have a custom Rhino plugin written in C# with a Windows Forms user-interface panel. In the panel, there is a button by which I can write some user-text attributes to Rhino objects. However, Grasshopper does not seem to get the modified user-text attributes without a manual refresh of the GH canvas. The attributes do appear in the user-text attributes window in Rhino immediately, but there seems to be something critical missing in triggering an event Grasshopper listens to.

I have tried both with Geometry Pipeline and Dynamic Geometry Pipeline, but both require the manual refresh.

This works automatically (without manual refreshing) if I just write some user-text attributes in Rhino and press Enter.

Can anyone confirm that it should work? That you can have a Rhino plugin which writes data to Rhino’s user-text attributes and Grasshopper gets the modified values right away? If, what is required from my plugin to “finish up” the modification of the selected objects? What does Grasshopper require to trigger recalculation when user-text-attributes are changed?

I have tried to follow this tip from Dale

but can’t seem to get it working.

I’ve also tried the CommitChanges() and Redraw() from this post:

I am running Rhino 7, SR36.

1 Like

@TuomasLehtonen, try this:

// Force GH canvas update
var canvas = Grasshopper.Instances.ActiveCanvas;
if (canvas != null)
{                
canvas.Refresh();
}
1 Like

Thanks,

I was having some problems getting any of the methods to work properly, but that was probably due to some mismatch in RhinoCommon package versions in my Visual Studio solution. I updated the Nuget packages and then used:

var ghDoc = Grasshopper.Instances.ActiveCanvas.Document;
ghDoc.NewSolution(true);

This at least did the trick. However, I know it is not the most elegant solution and probably Grasshopper should see the modified user-text-attributes and trigger a new solution without any manual workarounds like this. @DavidRutten called it carpet bombing here:

But at least the bombing works.

BTW, I couldn’t make the canvas.Refresh() work.