Layout - making projected views

I’m working on a script to make projected views, spoiler:

but I have trouble finding out which view the detail is, currently I’ve done it through a hack which introduces some limitations. How can I know if the View’s projection is world top, front, left, bottom, or back?
Any ideas how I can make it work that clicking left of the top view also gives me the left view instead of a tilted top view?

projectedview-demo.3dm (279.9 KB)

code:

3 Likes

@dale script is already lot better now. But what I can’t seem to find is how to change the title of the detail:

I can see I can get the title (sort of) here:
https://developer.rhino3d.com/api/RhinoCommon/html/P_Rhino_DocObjects_DetailViewObject_DescriptiveTitle.htm

But can’t find a way to set it

Hi @Gijs,

A detail has a viewport, and a viewport has a name property.

RhinoViewport.Name

– Dale

Hi @dale ,

when I try this with a detail view, I can retrieve it’s viewport title trough detail.Viewport.Name, but when I try to set a name through detail.Viewport.Name = “test” it doesn’t work. What am I missing?
Setting the detail name through detail.Name does work.

sample that should work with the 3dm I posted in first post:

    import Rhino
    import scriptcontext as sc
    import rhinoscriptsyntax as rs


    detailview = rs.GetObject("select detail for projected view",32768, preselect=True)

    d=rs.coercerhinoobject(detailview)
            
    print d.Viewport.Name #prints 'Top'
    d.Viewport.Name = "newtitle"
    d.Name="detailname"
    d.CommitChanges()

Hi @Gijs,

Sorry I missed this. Try the following:

import Rhino
import scriptcontext as sc

def test_rename_detail():
    
    filter = Rhino.DocObjects.ObjectType.Detail
    rc, objref = Rhino.Input.RhinoGet.GetOneObject("Select detail to rename", False, filter)
    if not objref or rc != Rhino.Commands.Result.Success: 
        return
    
    detail_obj = objref.Object()
    if not isinstance(detail_obj, Rhino.DocObjects.DetailViewObject):
        return
    
    viewport = detail_obj.Viewport
    title = viewport.Name
    viewport.Name = title + "-Modified"
    
    detail_obj.CommitViewportChanges()
    sc.doc.Views.Redraw()

if __name__ == "__main__":
    test_rename_detail()

– Dale

1 Like

thanks @dale it works well now

@dale is it possible somehow to show the user a preview of the detail view I am trying to create? Right now all I display is a bounding rectangle of it (as shown in the video in the beginning of my post) but this is not very informative.

Hi @Gijs,

You might think about capturing the view that will end up in a detail to a bitmap and then draw that bitmap in a conduit.

– Dale

@dale, so far can’t get it to work, so I tried this sample:
https://developer.rhino3d.com/api/RhinoCommon/html/M_Rhino_Display_DisplayPipeline_DrawBitmap.htm

and it seems to be working only in Rhino 5?
How do I make this work in Rhino 6/7?

edit: found the issue:
e.Display.DrawBitmap(self.display_bitmap, 50, 50, System.Drawing.Color.Red)
should be:
e.Display.DrawBitmap(self.display_bitmap, 50, 50)

@dale DetailView does not inherit from RhinoView, so there is no CaptureToBitmap() method. Do you have any suggestions how I can capture the content of a detailview?

Hi @Gijs,

I haven’t tried. But this version of ViewCapture.CaptureToBitmap should work.

– Dale