Is it possible to control the display on / off option using the API? [python]


Hello Please let me know if there is an API that can control the check / uncheck of Clipping Plane in Display mode as shown above. I would appreciate it if you could show me an example too.


Yes, you should be able to do it like this (I modified another sample from RhinoCommon doc. online to turn off clippingplane display for selected displaymode):

    import Rhino
    import scriptcontext

    # The following example demonstrates how to modify advanced display settings
    # using RhinoCommon. 

    def AdvancedDisplay():
        # Use the display attributes manager to build a list of display modes.
        # Note, these are copies of the originals...
        display_modes = Rhino.Display.DisplayModeDescription.GetDisplayModes()
        if not display_modes: return Rhino.Commands.Result.Failure

        # Construct an options picker so the user can pick which
        # display mode they want modified
        go = Rhino.Input.Custom.GetOption()
        go.SetCommandPrompt("Display mode to modify mesh thickness")
        opt_list = []
        for i, mode in enumerate(display_modes):
            english_name = mode.EnglishName
            english_name = english_name.translate(None, "_ -,.")
            opt_list.append( go.AddOption(english_name) )

        # Get the command option
        if go.CommandResult()!=Rhino.Commands.Result.Success:
          return go.CommandResult();

        selected_index = go.Option().Index
        selected_description = None
        for i,option in enumerate(opt_list):
            if option==selected_index:
                selected_description = display_modes[i]
        # Validate...
        if not selected_description: return Rhino.Commands.Result.Failure

        # Modify the desired display mode to turn off ClippingPlanes display
        selected_description.DisplayAttributes.ShowClippingPlanes = False
        # Use the display attributes manager to update the display mode.
        # Force the document to regenerate.
        return Rhino.Commands.Result.Success

    if __name__=="__main__":

@tr1004sm, @Jarek,

below is a simple toggle for the current vievport display mode, works in V6 only:

import Rhino
import scriptcontext

def DisplayModeToggleClippingPlanes():
    if Rhino.RhinoApp.ExeVersion < 6: return
    dmd = scriptcontext.doc.Views.ActiveView.ActiveViewport.DisplayMode
    state = dmd.DisplayAttributes.ShowClippingPlanes
    dmd.DisplayAttributes.ShowClippingPlanes = not state
if __name__=="__main__":


1 Like