Detail Views and Clipping Planes

Hi Everyone,

(a little background)
I’m writing an analysis plugin that displays data with a custom display conduit, showing different data on different viewports based on internal settings of the plugin. Thus I have on one layout page several detail objects which should all show the same view.
(End background)

I needed to write a tool which would synchronize all of the details on one page, so that they all show the exact same view. Many items can be synchronized:

  • Camera Settings
  • Zoom
  • Display Mode
  • Viewport Lock
  • Grids / Axes
  • Clipping Planes
  • Layer States (visible, color, plot width/color)

Since I might not be the only one finding this useful I split it out into a separate plugin:
DetailViewSynchronize.rhp (46.5 KB)

But it does not work completely - the clipping planes aren’t always synchronized. If, in my reference viewport, a clipping plane is disabled, intending to disable it in all of the other viewports, it simply doesn’t happen. Is the function ClippingPlaneObject.RemoveClipViewport broken?

Also, if a clipping plane is on in the reference viewport (and off in all others), it does get turned on in all viewports but inevitably one viewport won’t redraw with the clip, though the clipping plane object properties say it should be active. (Oddly it’s never the same viewport that doesn’t get updated.)

You can play with the plugin in this sample model: details.3dm (331.8 KB)

Here’s the source code of the entire function:
DetailViewSynchronize.cs (12.0 KB)

and the snippet related to the clipping plane is:

OptionToggle OT_v_clipplanes = new OptionToggle(true, "No", "Yes");
RhinoObject[] clipplanes = doc.Objects.FindByObjectType(ObjectType.ClipPlane);
Dictionary<ClippingPlaneObject, bool> Dict_ClipPlanesActiveInDetail = new Dictionary<ClippingPlaneObject, bool>(clipplanes.Length);
foreach (RhinoObject clip in clipplanes)
{
    ClippingPlaneObject cps = clip as ClippingPlaneObject;
    Dict_ClipPlanesActiveInDetail.Add(cps, cps.ClippingPlaneGeometry.ViewportIds().Contains(DVO_current.Id));
}
.
.
.
foreach (DetailViewObject detail in DVOa_DetailsOnCurrentPage)
 if (OT_v_clipplanes.CurrentValue)
 {
    foreach (var cps in Dict_ClipPlanesActiveInDetail)
    {
        if (cps.Value)
        {
            // not sure whether to do it in the ClippingPlaneGeometry or with the ClippingPlaneObject method
            //cps.Key.AddClipViewport(detail.Viewport, true);
            cps.Key.ClippingPlaneGeometry.AddClipViewportId(detail.Viewport.Id);
        }
        else
        {
            //cps.Key.RemoveClipViewport(detail.Viewport, true);
            cps.Key.ClippingPlaneGeometry.RemoveClipViewportId(detail.Viewport.Id);
        }
        cps.Key.CommitChanges();
    }
}

Thanks for your help everyone.
This is similar to:
How do we remove viewportid from clipping plane
Disable/enable clipping plane

Also in YouTrack:
https://mcneel.myjetbrains.com/youtrack/issue/RH-34047
https://mcneel.myjetbrains.com/youtrack/issue/RH-32856
Something happened here but not completely?
@dale
@rajaa Did you get it to work in your SectionTools?