How to update geometry preview, and then dispose of geometry inside of a loop C#

I’m trying to create a custom zero-touch node using C# that will highlight a chosen curve as colored geometry in the preview window, while remaining inside of a loop.

So far I can only preview geometry by returning it, and I can’t apply a color to the geometry without using the Display.ByGeometry node on the canvas.

Here is the most sensible attempt at this I have so far, and it still doesn’t work. The code runs without errors, but I also don’t perceive any change on the display.

public static void ColorTest (Curve crv)
    Cone cylinder = Cone.ByPointsRadii(crv.StartPoint, crv.EndPoint, 1, 1);
    DSCore.Color red = DSCore.Color.ByARGB(255, 255, 0, 0);
    for (int i = 0; i < 1000; i++)
        Display.Display.ByGeometryColor(cylinder, red);

I have been examining the API, and am thinking that maybe I need to trick Dynamo into thinking that the node has executed. However, since I am not intimately familiar with the Dynamo API I don’t really know where to begin. Any help would be appreciated.

Try hiding and unhiding the object in the view. Here’s a hack I did with Python which could easily be ported to C.

@zltrattner yes, you’ve hit the nail on the head - Dynamo is not going to ask for render geometry from your function until it returns.

you cannot do this by writing a ZT node.

You need to write a UI node which inherits from node model and then push tasks onto the dispatcher which request the background preview to update - it’s going to be tough I think, I guess you could push sleep tasks as well.

I think this could be a very interesting sample.

@Thomas_Mahon - thats a very clever idea but only works in the context of revit right?

@Michael_Kirschner that’s correct. If its the background preview in Dynamo @zltrattner is referring to, then my suggestion is going to be of no use!