ZoomBoundingBox() one object at a time

Getting my feet wet in C# (oh boy what a difference from py) and trying to rework some of the tools I’ve made in python in the past using C# instead.
Right now I am just trying to zoom on every object after the selection is made (if it’s valid brep) after that I’ll need to perform some operations to the object but I am hung up on the 1st step.
Here is what I have as a snippit

		RhinoList<Brep> breps = new RhinoList<Brep>();
		var view = doc.Views.ActiveView;

		for (int i = 0; i < go.ObjectCount; i++)
		{
			var brep = go.Object(i).Brep();

			if (brep != null)
				view.ActiveViewport.ZoomBoundingBox(brep.GetBoundingBox(false));
				view.Redraw();
				breps.Add(brep);
		}

I know the loop does run the correct amount of times based on the selection, but the issue I am having is that the viewport only zooms onto the last object and not in between. :neutral_face:
Any help is much appreciated.

Hi @mikhail1,

Calling RhinoView.Redraw sends a Windows paint message (WM_PAINT) to the view window. Paint messages are pretty low priority. So in your case, Windows basically eats all the paint messages except the last one. You either need to give Windows time to process the messages, or you can “pump” the message queue using RhinoApp.Wait(), which is what the attached sample does.

TestMikhail.cs (1.4 KB)

Hope this helps.

– Dale

1 Like

Never though I would have an issue of something working too fast, very different world than python :smile:
Thank you for the help!