Override viewportproperties to get coloured Text


#1

Hi,

i got stuck showing text in the viewport.
I am in visual studio, i already managed to get a poitncloud displayed, but the text wont show up.
I am not sure what the error is,i dont get any error, the text just dont shows up.
before


Thanks for any hint!
CurveSlopeAnalysis.rar (23.8 KB)
Edit: GH file and screenshot displayOverride.gh (7.8 KB)


(David Rutten) #3

The text size for 3D text is in world units. Are you sure it’s big enough to actually see the text in your viewport projection?


#4

Hi David,

thanks for answering.
I just added a height input to check in my document, but no text appears.
Am i right that world units are my document units?


(David Rutten) #5

Basically yes. Just remove whatever unit symbol you’re using and the number you’re left with is the world unit. So if your grid lines are 1 unit apart, then you know how big 1 is.


(David Rutten) #6

Perhaps the attached helps. text3d.gh (6.4 KB)


(David Rutten) #7

And if you want to draw text at screen scale, you can do this:

double ppu;
args.Viewport.GetWorldToScreenScale(_points[i], out ppu);

plane.Origin = _points[i];
Rhino.Display.Text3d text = new Rhino.Display.Text3d(_text[i], plane, 20 / ppu);

#8

Hi @DavidRutten,

thanks for the examples, i tried different things, i tested if the lists i send are full(points,text,colour), and yes they are.
Could the reason be something with the boundingBox or the planes i make?


Or how could i check if ther was a text made, maybe just in an unexpected location?
Thanks!


(David Rutten) #9

I can’t see anything wrong with the code, but it’s all conjecture until I can actually run it.
You could try drawing something else at your point locations (circles, just points, lines from the world origin to your points, anything that might help you debug).

Do note that if your points are outside of the clipping bounds then they will not show up. You must return a clipping boundingbox which is big enough to contain all the geometry you wish to draw.


#10

HI @DavidRutten,

I the points are visible, just the text is miisng. So i assume the clippingBox should be big enough.
I uploaded in the question the visual studio files, i will upload a newer one here, maybe you could have a look? Just need to pack it to can upload on this forum.
Thanks for all the time you already spent one this!
CurveSlopeAnalysis.rar (29.8 KB)


(David Rutten) #11

The problem is you never actually assign your class level variables _colours and _text. You are maintaining separate collections inside SolveInstance() and never copy the values out into your class level variables.

You should put a breakpoint in your DrawViewportWires method and then you can inspect your variables. If you cannot set breakpoints and debug your code then that should be priority #1. Developing without a debugger is not something you should settle for.

CurveSlopeAnalysisComponent.cs (6.0 KB)

ps. I made some changes to the naming of variables in the code. I’m just so used to my scheme that I find it really hard to see bugs otherwise. You of course do not have to adhere to my personal preference.


#12

Hi @DavidRutten,

thanks a lot!

Right now I am looking how to set up the debugger, you were completly right, i need to improve my vs skills to a basic level.

I am really happy you revised my piece, also the renaming, for me its a really nice learning
resource!

Thanks for taking the time!

Have a nice day!