Changes applied in a python script propagate only to the GUI but don't get displayed

I’m trying to write a script that applies a color gradient to a markups curve.

All the changes are visible in the GUI, but the displayed curve does not change. To change the curve I have to manually click on something in the GUi (to update it?).

This is my code

# get color table
iron = slicer.util.getFirstNodeByName("Iron")

curveNode = slicer.mrmlScene.GetFirstNodeByName("MarkupsCurve_2")
dispNode = curveNode.GetDisplayNode()
dispNode.SetActiveScalarName("PedigreeIDs")
dispNode.SetAndObserveColorNodeID(iron.GetID())
dispNode.SetScalarVisibility(1)

This is how it looks after the code is executed (the Iron color table is not applied):

Then, if I e.g. click twice on the ‘Visibile:’ checkbox, the view gets updated (the Iron color table is applied):

You can make the coloring appear like this:

iron = slicer.util.getFirstNodeByName("Iron")
curveNode = slicer.mrmlScene.GetFirstNodeByName("OC")
dispNode = curveNode.GetDisplayNode()
dispNode.SetAndObserveColorNodeID(iron.GetID())
dispNode.SetActiveScalarName("PedigreeIDs")
dispNode.SetScalarVisibility(1)
dispNode.UpdateAssignedAttribute()
dispNode.Modified()

The last two lines should not be needed (should be called automatically internally) - I’ll fix that soon in Slicer core.

The issue is now fixed, in Slicer Preview Releases downloaded tomorrow or later the last two lines of the script above will not be necessary anymore.