Redraw component on grasshopper canvas after changing its pivot

Hi all

I don’t understand how to force grasshopper to redraw components on the canvas after I moved them.
I have a test code like this

var comp = GrasshopperDocument.ActiveObjects().First();
comp.Attributes.Pivot = new System.Drawing.PointF();

It should move the first component to the top left corner of the canvas but nothing happens. In fact, the component is moved but the canvas is not redrawn. If I try to drag that component, it will instantly jump to the 0,0 point.

I tried to call
Grasshopper.Instances.RedrawCanvas(),
Grasshopper.Instances.ActiveCanvas.Update()
Grasshopper.Instances.ActiveCanvas.Refresh()
no success.

Hello,

I think you need to tell the component that his layout has expired, so it actually gets redrawn when the canvas is refreshed.

comp.Attributes.ExpireLayout();
1 Like

awesome! thanks