Display Conduit redraw

I try to get my head around display conduits. For testing I wrote some simple code in a c# node, that displays 3d text. The problem is, that the display never gets redrawn. Every time i trigger the code new text is added, but it never disappears.
Thanks for any answer.
Best M.

MyConduit myConduit = new MyConduit();
Rhino.RhinoDoc doc = Rhino.RhinoDoc.ActiveDoc;

      for(int i = 0;i < plns.BranchCount;i++){
        GH_Path p = plns.Paths[i];
        for(int j = 0;j < plns.Branch(i).Count;j++){
          if(plns[p, j] == null)continue;

          Rhino.Display.Text3d txt = new Rhino.Display.Text3d("test", plns[p, j], s);
          txt.VerticalAlignment = Rhino.DocObjects.TextVerticalAlignment.Middle;
          txt.HorizontalAlignment = Rhino.DocObjects.TextHorizontalAlignment.Center;
          txt.FontFace = "Arial";

      myConduit.Enabled = true;
      myConduit.Enabled = false;
      myConduit = null;

class MyConduit : Rhino.Display.DisplayConduit
    private List<Rhino.Display.Text3d> lsText;
    public MyConduit(){
      this.lsText = new List<Rhino.Display.Text3d>();
    public void Add(Rhino.Display.Text3d txt){
    public void Clear(){
    protected override void CalculateBoundingBox(Rhino.Display.CalculateBoundingBoxEventArgs e)
      foreach(Rhino.Display.Text3d txt in this.lsText){
    protected override void DrawForeground(Rhino.Display.DrawEventArgs e)
      foreach(Rhino.Display.Text3d txt in this.lsText){
        e.Display.Draw3dText(txt, System.Drawing.Color.Green);

Hi @mwittich,

Is this code part of a plug-in command, a custom Grasshopper addon, or embeded in a C# component inside of a GH definition? Perhaps you can provide something we can run here?

– Dale

The myConduit variable is probably defined in a local scope.
You do not have to set “my Conduit” with “new MyConduit ();” every time you redraw your scene.

Oops! sorry I must be wrong, yes answer to Dale.

Hi Dale,
it´s just embedded in a C# Component. Sorry I should have added a file before.
Thanks for your reply.
Best M.
conduitTest.gh (5.1 KB)

I’ve moved this to the Grasshopper category.

– D

Is there any solution for this? I am now facing similar problem. Thanks

Yes, when a C# component is recompiled, the old code still exists. Grasshopper itself no longer calls it, but any events it has subscribed to are still active.

You can either check the validity of your code by checking whether the Component field on your script is null (I’m pretty sure it’s blanked whenever the code goes stale), or better yet, use the in-built preview mechanism.

Click on the eye icon in the code editor top right, and the methods for participating in grasshopper previews will be inserted in your code.