Rhino8 SetPerViewportVisible not working

Rhino8 SetPerViewportVisible not working between two StandardModelingViewport.rhino7 Layer.SetPerViewportVisible is working but Rhino8 isn`t.Is this a bug or is it designed like this?

Hi @王佳伟,

Most likely not.

Can you share some sample code, we can run here, that does not work for you?

Thanks,

– Dale

Hi @dale Thank you for your reply,

Rhino7 like this.


open it in Rhino8.

I renamed the two viewports. The one on the left is called “SketchView” for designing, and the one on the right is called “SolidView” for automatically generating for display based on the design.
The two viewports display content separately.
But there are some situations where the content of SketchView needs to be placed in SolidView.
For example, if you are not sure of the specific location during design, you need to confirm it in SolidView.

code like this:

// search wallLayer
var wallLayer = RhinoDoc.ActiveDoc.Layers.FindName(“Sketch::Wall”);
wallLayer?.SetPerViewportVisible(SketchView.ActiveViewportID, true);
wallLayer?.SetPerViewportVisible(SolidView.ActiveViewportID, false);

// user click show skechviewcontent to solidviewcontent

wallLayer?.SetPerViewportVisible(SketchView.ActiveViewportID, true);
wallLayer?.SetPerViewportVisible(SolidView.ActiveViewportID, true);

// user click hide wallLayer at solidviewcontent

wallLayer?.SetPerViewportVisible(SketchView.ActiveViewportID, true);
wallLayer?.SetPerViewportVisible(SolidView.ActiveViewportID, false);

this is some code,you can run it.
I want this text to be displayed on the top viewport but not in the right viewport.
but it not working.



      protected override Result RunCommand(RhinoDoc doc, RunMode mode)
      {
          var layerIndex = doc.Layers.Add("test", System.Drawing.Color.Red);
          doc.Objects.AddText("ViewportVisibleTest...", Plane.WorldXY, 10, "Microsoft YaHei UI", false, false, new ObjectAttributes()
          {
              LayerIndex = layerIndex,
          });
          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, true);
          layer.SetPerViewportVisible(secondView.ActiveViewportID, false);
          return Result.Success;
      }

Hi @王佳伟,

Thanks, I’ve logged the issue.

https://mcneel.myjetbrains.com/youtrack/issue/RH-81265

– Dale

Thanks,
Our plugin is waiting for this issue to be upgraded to Rhino8,
Which version can be released for this issue?

Hi @王佳伟,

I hope to have time to look at this in a few days. I don’t have a timeframe for fixing.

– Dale

Hi @王佳伟,

Until this is fixed, you might look at the new Layer.ModelIsVisible property, which basically does the same thing.

– Dlae

Hi @dale
It can only control whether it is visable in the model view or detail view.
But cannot control the layervisable betwoon two model view.