Isolated viewport

Hi all,

Is it possible to create a custom viewport to show just one object?

I’d like to batch process various outputs from a file through scripting, ie parsing different rooms in a building and outputting a page per room with some info. Each of these pages can have several screenshots from the Rhino viewport with various overlays such as daylight results.

My workflow currently is:

  • hide everything
  • make a new popup viewport to make sure that it has the right display modes etc
  • bake temp items including attributes for line thickness etc
  • zoom to a boundingbox
  • updateviewport()
  • make a screenshot
  • delete temp stuff
  • repeat

alternative workflows could be using DrawMethods and Conduit but I found this easier (although slower).

Problem is if I have existing stuff in my viewport that’s locked etc its difficult to hide. And ideally I’d only update this “extra” viewport to take screenshots and not all of my viewports.

So heres the real question:
Is it possible to make a new floating viewport that will hide everything in my file except a list of specific items? While maintaining all the existing viewports?

Hey @sonderskovmathias,

Overall it sounds like your end goal is to export screenshots that focus on only a given set of objects.

Something I’ve never tried personally, but always wondered about is the ViewportId property on object attributes.
https://developer.rhino3d.com/api/rhinocommon/rhino.docobjects.objectattributes/viewportid

It might be fast to give everything an ID of a top viewport, and just assign the Perspective ViewportId to the items you care about. It shouldn’t require you to modify any objects and you can reset to Guid.Empty once you’re done.

– cs

My end goal exactly. Unfortunately the ViewportId only works for page objects (I think?).
Didnt get it to work with the below:

  List<Guid> guids = new List<Guid>();

    foreach (Rhino.Display.RhinoView rv in Rhino.RhinoDoc.ActiveDoc.Views)
    {
      guids.Add(rv.ActiveViewportID);
    }
    Guid vpGuid = guids[0];

    ObjectAttributes atts = new ObjectAttributes();

    atts.ViewportId = vpGuid;

    Rhino.RhinoDoc.ActiveDoc.Objects.AddBrep(box, atts);

I’ve had a crack at it, and written a Grasshopper Example that works nicely for me!


Example.3dm (43.2 KB)
ViewNiche.gh (10.0 KB)

ObjectEnumeratorSettings settings = new ()
{
    LockedObjects = true,
}

var rhinoThings = RhinoDoc.ActiveDoc.Objects.GetObjectList(settings);
foreach(var rhinoThing in rhinoThings)
{
    rhinoThing.Attributes.ViewportId = viewId;
    rhinoThing.CommitChanges();
}

Of course you’d need to then reset everything at the end.

ObjectEnumeratorSettings settings = new ()
{
    LockedObjects = true,
}

var rhinoThings = RhinoDoc.ActiveDoc.Objects.GetObjectList(settings);
foreach(var rhinoThing in rhinoThings)
{
    rhinoThing.Attributes.ViewportId = Guid.Empty;
    rhinoThing.CommitChanges();
}

And ideally you’d keep track of any objects that had view specific Ids in the first place, and carefully reset those.

– cs

1 Like

This is pretty cool! I wonder what caused it not to work in my logics. Anyway.

Still missing a way to tell that viewport to only show the objects with that Id assigned (and not the rest of the scene).

I could definately find usage for your code anyway (imagine two synchronised perspectives, one with my geometry and one highlighting meta data, etc).

Hi Mathias,

here is one more idea: what if you created a display mode that shows nothing (no type of object is allowed, all edge thickesses set to 0/invisible). Assign that mode to your new custom floating viewport and then use per-object display mode there for the objects you want to see.

Here is a quick test and a ‘nothing’ display mode - obviously many ways and what-ifs to code it, but this could be a simple solution (with a bit more headache for block instances, but doable as well)
NOTHING.ini (13.7 KB)

hth,

–jarek

1 Like

That’s a very convenient workaround!

It’ll definately solve my needs for now.

Also a good hack to hide all rhino geometry for a quick grasshopper-only view

Thanks :slight_smile:

Capital idea! Very cool solution :slight_smile: