DrawViewportWires called perpetually when "perspective type" viewport is active, normal behavior in others

hi

i wrote a small c# plugin to generate a textdot with font&colour choices, mostly to see how previewing works. i log the various internal overrides, especially DrawViewportWires where the preview logic is done.

when i drop my component on the grasshopper canvas the preview fundamentally works as expected
… however …

if i activate one of the (top, right, left …) viewports the DrawViewportWires is called once for each viewport displayed, so when the standard 4 are displayed, DrawViewportWires is called 4 times, once for each viewport and the preview is as expected.

however if i activate the one of the perspective type viewports, DrawViewportWires gets called in a continuous loop, basically a call to each viewport on the screen, over and over …
cpu goes up to about 2% and the memory utilization keeps ever increasing, i assume it will eventually fail but i have a lot of memory and the leak is small…

if i select another view port, say top, the looping stops … and after a while (few minutes) the memory goes down slowly to the original values…

i assume its a bug of some sort??

regards

eric

i was going to attach the code, but can’t figure how to attach a file…

Some code will definitely be required. You can upload files via the button on the toolbar which looks like a bar with an up arrow. If the file type you have is now allowed, then zip it first.

WW_TextDot - Copy.cs (7.4 KB)

that was easy … i removed unnecessary references to other modules… (that is why name has Copy in it)

with the defaults, it will generate a dot when placed on canvas, no inputs need to be set to see the issue …

regards

eric

hi

did i send what you wanted, or more info required

regards

eric

Sorry, I missed your response. Yes it’s what I needed. The DrawViewportWires method is called once for every viewport while redrawing, so you really don’t want to do anything heavy during the methods. Adding objects to the document during every redraw definitely falls into this category.

If you want to add objects to the Rhino document, do so in SolveInstance or AfterSolveInstance. Only use the drawing methods to draw stuff, not modify the document.

Specifically, adding objects requires a redraw, so adding objects from within a redraw will cause an infinite loop of redraws triggering redraws.

hi

ok i understand what you are saying, but why 2 different behaviors??

  1. if i select, for example TOP viewport, then the refresh is done once
  2. if i select Perspective, it goes onto a loop

i don’t really want the objects in the document since i am not trying to bake them, i just want a “preview”
with selected colors and layers, its for debugging since it basically enumerates the major parts of the selected geometry and adds textdots …

eric

Here’s how to draw dots without adding them to the document.

dot drawing.gh (4.2 KB)

hi

thanks, so much easier!!

eric