Batch change script or command to change the detail viewport display mode in layouts?

I’m working on large projects that require anywhere from 2-6 details on a layout. Is there a script, command, or plugin that is available that would allow me to batch change the display mode of the details on a current page or all pages at once?

I currently need to click into the detail to set the display mode for that detail and this becomes very tedious when I need to change many details in a set.

The match properties do not accomplish this task and this would be a great addition for layouts.

Any help is greatly appreciated! :grinning:

Hi,

See if the attached script works for you:
set_all_details_mode.py (1.7 KB)

import Rhino
import rhinoscriptsyntax as rs
import scriptcontext as sc
"""
2021 03 09 script by Willem Derks (willem@onepush.nl) per request:
https://discourse.mcneel.com/t/batch-change-script-or-command-to-change-the-detail-viewport-display-mode-in-layouts/120014
"""

def set_detail_displaymode(detail_id,mode_name):
    
    rs.UnselectAllObjects()
    rs.SelectObject(detail_id)
    rs.Command('-Detail Enable ', echo=False)
    rs.Command('-SetDisplayMode Viewport=Active Mode={} '.format(mode_name), echo=True)
    rs.Command('-Detail EnablePage ', echo=False)
    rs.UnselectAllObjects()



def get_current_layout_details():
    
    current =  sc.doc.Views.ActiveView.MainViewport
    current_id = current.Id
    current_details = []
    detail_ids = rs.ObjectsByType(32768)
    for detail_id in detail_ids:
        geom = rs.coercerhinoobject(detail_id)
        if geom.Attributes.ViewportId == current_id:
            current_details.append(detail_id)
    return current_details



def set_all_details_displaymode():
    
    #get displaymode names
    mode_names = [mode.LocalName for mode in Rhino.Display.DisplayModeDescription.GetDisplayModes()]
    
    mode_name = rs.ListBox(mode_names, 'choose mod eto set details in')
    if not mode_name : return
    

    for view_name in rs.ViewNames(return_names = True, view_type=1):
        
        rs.CurrentView(view_name)
        
        detail_ids = get_current_layout_details()
        for detail_id in detail_ids:
            set_detail_displaymode(detail_id,mode_name)
            
            
    rs.EnableRedraw(True)
    
    
    
set_all_details_displaymode()

-Willem

1 Like

This is fantastic!! Thank you kindly it works like a charm.

1 Like