Exclude objects display in viewport

Hello,
It is possible to selective exclude objects from display during operations on viewport (rotation, move, etc.)?

Yes, you need to create a DisplayConduit for that. In the conduit, you can override the ObjectCulling method where objects can be culled (removed) from the scene.

In the CullObjectEventArgs object that is passed into this method, the Display has a property IsDynamicDisplay, which is true when the viewport has rapid changed, for example due to rotations or panning.

Up to you to implement this :smile:

1 Like

Thanks, menno

I have one more question. Why culling objects only when I change the view with SpaceNavigator but with mouse is no longer culling.

        protected override void ObjectCulling(Rhino.Display.CullObjectEventArgs e)
        {
          // if dynamic display

          if(e.Display.IsDynamicDisplay)
          {
            if(e.RhinoObject.Name == "tocull")
              e.CullObject = true;
          }
        }

no idea, sorry…

I know I have to put everything in the PreDrawObject method and then it works fine.

I have one problem, I wanted to get the speedup viewport by excluding objects from drawing. With thousands of objects it does not work, even though the objects are not drawn - viewport is still slow. There is another way to speed up the viewport?

Maybe Hide the objects, temporarily?

I know it would help, but I do not know how to implement this function in DisplayConduit so that dynamically hiding objects when the view is rotated.

How about enabling BoundingBox display in the current display mode ?

btw. do you want to hide your own object while the view is rotated or all other objects and keep your object visible ?

c.

Yes, I want to hide my objects, there are tens of thousands and, therefore, Rhino viewport slow. I came up with the idea now: switching ObjectTable with own ObjectTable without objects do not want do draw durning rotate, pan viewport. Perhaps it can be implemented but I have no idea how.

Ps. BoundingBox feature does not help.

I tried this but it’s still slow, because the hiding and showing takes time.

 protected override void PreDrawObject(Rhino.Display.DrawObjectEventArgs e)
    {
    
      if(e.Display.IsDynamicDisplay)
      {
        if(e.RhinoObject.Attributes.LayerIndex == e.RhinoDoc.Layers.Find("culling2", true))
        {

          e.RhinoDoc.Objects.Hide(e.RhinoObject, true);
        }


      }

      e.RhinoDoc.Objects.Show(e.RhinoObject, false);
    
    }

@namarcin,

did you try to change the layer visibility instead of individual objects ? With so many objects, i guess it takes longer to read the layer index from the attributes. Maybe you can get the layer once in a global variable and then set layer.IsVisible = false; after IsDynamicDisplay ?

You might check before, if the layer is not hidden yet,otherwise it will slow down again.

c.