Update GH canvas

Hi all,

I have a little Python script that updates some stuff on the GH canvas. For example, the snippet below updates the size of the text in Scribbles. It all works fine, except that I can’t get the canvas to automatically display the changes. (After the script has run, I need to move my scribble a bit, then the canvas updates.)

import Grasshopper as gh
import checkTypes
ghdoc = gh.Instances.ActiveCanvas.Document
for obj in ghdoc.Objects:
    if checkTypes.isScribble(obj):
      old_font = obj.Font
      new_font = gh.Kernel.GH_FontServer.NewFont(old_font.FontFamily.Name, 20, old_font.Style)
      obj.Font = new_font

I have been looking for the canvas update method to refresh the canvas to the latest state. Any suggestions?

Patrick

1 Like

Try calling obj.ExpireSolution(False) after setting the font.

Edit: But if you just want to recompute the whole canvas, try these solutions:

Thanks… This works fine
gh.Instances.ActiveCanvas.Document.NewSolution(True)