Display Legend on viewport


(Shimpei) #1

Hi everyone,

I want to draw Legend on the viewport scripting C#.
Here is my image which is what I want to do.

I want to make Legend’s color depend on the value which my component calculates.
And Legends will not be moved even when I panned and rotate viewport.

I’ve already draw 3Dtext using DrawViewportMeshes.
I think what I want is something to do with DrawViewportmeshes, but I couldn’t find how to get viewport coordinete.

Would there be any way to do this?


(Shimpei) #2

I found Draw2dRectangle class.
I guess this will be useful for me to draw legend.

(Dale Fugier) #3

Hi @11194,

DisplayPipeline.DrawBitmap might be what you need.

– Dale

(Shimpei) #4

Hi Dale,
Thank you for the reply!
Sorry for my late.

I made component displaying legend on viewport with using Draw2d, but It’s location looks bad…

int start = 400;
int length = 400;
for(int j = 0;j < div;j++){
Rectangle rec = new Rectangle(0, length / div * j + start, 50, length / div);

I forcibly modified ‘start’ and ‘length’ to adjust rectangle location every single time.

Do you know how to get position of corner at lower left on viewport?


(Dale Fugier) #5

Hi @11194,

Use RhinoViewport.GetScreenPort.

– Dale