Grasshopper Display TextDot problem

I am trying to make a grasshopper component that displays textdots on rhino viewport.
I have found following rhino example.

and I have tried to replicate as follows.

Problem I have is that displayed text dots do not refresh and just piles up on the viewport everytime input to the scripted component changes. see below.

I do not fully understand how or what exactly DisplayConduit class does but I think I need some way to clear previously displayed objects cleared before declaring custom displayconduit but don’t know how. (6.6 KB)

private void RunScript(List<Point3d> points, List<string> texts, ref object A)
  _dots = points.Select((p, i) => new TextDot(texts[i], p));
// <Custom additional code> 
private IEnumerable<TextDot> _dots;
public override BoundingBox ClippingBox
    return new BoundingBox(_dots.Select(d => d.Point));
public override void DrawViewportWires(IGH_PreviewArgs args)
  foreach (var dot in _dots)
    args.Display.DrawDot(dot, Color.Black, Color.White, Color.Black);
} (4.7 KB)


Thank you @Mahdiyar. that is exactly what I wanted.

I just have few more questions. Because I am very new to coding,

dispite no code is implemented to display textdots in the runscript method,

how is DrawViewportWires method called??

First things first:

Assume that you have different colors et all: Meaning that you should assign a proper (string) attribute in order to sample/clear all the previous dots:

See attached as an entry level take on dots: (124.2 KB)

1 Like