Clipping planes on for details by name

Bumping an oldie (sorry, it seemed better to make this a new thread. Related thread below). RhinoScript question for the gang. @nathanletwory

I’m trying to associate clipping planes with certain layouts’ details. The clipping planes are named with the same prefix (delimited with “_”) as the layouts they’re supposed to be turned on for, and they should be off, unclipped, for all other views in the model. Currently, I have one detail per layout.

The naming logic works, but I’m failing to get the clipping planes to turn on or off using Rhino.ClippingPlaneView.

It’s difficult to figure out what a “detail name” is. If the detail object is unnamed, the Rhino Layout window shows it as “Detail”. If it’s named, fine, I’d think that that would count as a “title”. Neither one seems to work… so I tried just sending an array of each layout’s detail views as identifiers (Rhino.DetailNames( , False) to Rhino.ClippingPlaneView but no dice.

Last iteration of .rvb and model below. Clearly not the world’s most efficient script but I didn’t want to start messing around with two dimensional arrays until I got the methods working.

I’m probably missing something obvious. Any thoughts welcome.

Thanks for reading.

test711_clippingplanesperlayoutname.rvb (1.9 KB)

240517_ClippingPlanesPerLayout.3dm (1.0 MB)

I don’t know the visual basic scripting API, so here is how I would do it in Python - this is for Rhino 7 (IronPython)

import scriptcontext as sc
import Rhino

# Get all clipping planes in document
cps = [o for o in sc.doc.Objects if isinstance(o, Rhino.DocObjects.ClippingPlaneObject)]

# Loop through _all_ views
for v in sc.doc.Views:
    # Do our magic only when we find a RhinoPageView
    if isinstance(v, Rhino.Display.RhinoPageView):
        # Get all details in our page view v
        dvs = v.GetDetailViews()
        for dv in dvs:
            # per detail view loop over all cps
            for cp in cps:
                # skip those without a name
                if not cp.Name:
                    continue
                # if we have a match between view and
                # detail viewport name add this detail
                # viewport to those to be clipped for
                # matching clipping plane
                if cp.Name.startswith(dv.Viewport.Name):
                    cp.AddClipViewport(dv.Viewport, True)

sc.doc.Views.Redraw()

I have a short recording of this in action:

I used this file that has two clipping planes, one layout with two details. Clipping planes have been named “[VIEWNAME]_cp” where [VIEWNAME] is replaced with the actual name. The details on the layout have been set to a [VIEWNAME] each, you can find them in the named views list.

SetViewsForClippingPlaneBasedOnName.3dm (64.9 KB)

2 Likes

Thank you very much for taking the time. It seems like this:

is important - true? Otherwise there doesn’t seem to be a way to access the detail’s “view name” through the API?

When you check the script carefully you’ll see that I am accessing the viewport name through the detail view dv.Viewport.Name where dv is a detail view that I got through the RhinoPageView.GetDetailViews() call earlier.

Right, I see that. I’m just asking if it’s also important to christen that detail view with a name?

dv.Viewport.Name

Edit: The answer is no. With this python script, it’s important just to have the view name simply titled, THEN to activate the detail, unlock it, and change the view. Kind of a crappy UI experience in Rhino 7 to get the detail to update to a renamed view but it does work.

Thank you again. I’ll take a stab at redoing a vb version when I get a chance.

1 Like