Rhino8 not visible objects in the current viewport can also be selected

Objects hidden in the viewport using Layer.SetPerViewportVisible can still be selected.

  1. Objects cannot be selected using mouse drag selection, but they can be selected using SelectAll
  2. Snap points of this Objects, still be captured.
  3. Objects can be selected with a single mouse click.
    I want the objects that are not displayed to be excluded from any UI interactions.

Hi -

You might want to post code and/or a 3dm file.
-wim

@wim Thank you for your reply.

This is the file I tested,you can try it.
layervisabletest.3dm (35.3 KB)
This is mycode:

public class MyRhinoCommand : Command
{
    public MyRhinoCommand()
    {
        // Rhino only creates one instance of each command class defined in a
        // plug-in, so it is safe to store a refence in a static property.
        Instance = this;
    }

    ///<summary>The only instance of this command.</summary>
    public static MyRhinoCommand Instance { get; private set; }

    ///<returns>The command name as it appears on the Rhino command line.</returns>
    public override string EnglishName => "MyRhinoCommand";

    protected override Result RunCommand(RhinoDoc doc, RunMode mode)
    {
        var layerIndex = doc.Layers.FindByFullPath("test", -1);
        if (layerIndex == -1)
        {
            layerIndex = doc.Layers.Add("test", System.Drawing.Color.Red);
        }

        var topView = doc.Views.Where(v => v.ActiveViewport.Name == "Top").FirstOrDefault();
        var secondView = doc.Views.Where(v => v.ActiveViewport.Name == "Perspective").FirstOrDefault();
        var layer = doc.Layers.FindIndex(layerIndex);
        layer.SetPerViewportVisible(topView.ActiveViewportID, false);
        layer.SetPerViewportVisible(secondView.ActiveViewportID, true);
        return Result.Success;
    }
}

Looking forward to your reply.

@wim @dale We can not go forward. Looking forward to the fix.

Perviewport visibility currently only works with detail viewports. There are large portions of the core that would need to be adjusted to accommodate for this in standard modeling views