Change Mesh Edge Thickness from python

Hi all!

I’m trying to change the Mesh Edge Thickness from a Rhino Display mode directly in Python. I could save a custom display mode somewhere in the server and use it company-wide but there are some IT issues that I cannot bypass at the moment, that’s why I need to change the display mode in each machine.

I can change the Mesh Wireframe Thickness using “DisplayAttributes.MeshSpecificAttributes.MeshWireThickness = int”, but that doesn’t overwrite the mesh edge thicknesses. If you set the MeshWireThickness to 0 but the MeshEdgeThickness is 2, edges will still show with a thickness of 2.

Does anybody know what’s the method to use and if it can be accessed via Python? I read the documentation, but the methods proposed do not work for Python so maybe I’m missing something out (https://developer.rhino3d.com/api/rhinocommon/rhino.display.displaypipelineattributes).

This is my code so far:

import Rhino

def SetMeshEdgeThickness(display_mode_name, edge_thickness):
    # Find the display mode by name
    display_mode = Rhino.Display.DisplayModeDescription.FindByName(display_mode_name)
    
    # Modify the mesh edge thickness
    display_mode.DisplayAttributes.MeshSpecificAttributes.MeshEdgeThickness = edge_thickness
    
    # Save the changes to the display mode
    if Rhino.Display.DisplayModeDescription.UpdateDisplayMode(display_mode):
        print("Set mesh edge thickness to {} for display mode '{}'.".format(edge_thickness, display_mode_name))
    else:
        print("Failed to update display mode '{}'.".format(display_mode_name))

# Example
SetMeshEdgeThickness("Shaded", 10)

And here is the error message:

Runtime error (MissingMemberException): 'MeshDisplayAttributes' object has no attribute 'MeshEdgeThickness'

Traceback:
  line 18, in SetMeshEdgeThickness, "<string>"
  line 27, in script

What Rhino version are you trying this with? It has been available only since August 2024 (committed to code in July 2024). So at least Rhino 8.12 is needed.

I was scripting it in Rhino 7, but it is also not working in my Rh8 version (Version 8 SR9
(8.9.24194.18121, 2024-07-12)). Is it a version problem?

Yes, I just mentioned you need at least Rhino 8.12

Hi @Pablo_Antuna_Molina, for Rhino 6 and 7 use MeshWireThickness instead of MeshEdgeThickness eg:

# for Rhino 6 and 7
display_mode.DisplayAttributes.MeshSpecificAttributes.MeshWireThickness

A small note, if the language your code runs on is non english, it could be that you cannot find the display mode by it’s english name. A workaround would be:

# find display mode by id
shaded_id = Rhino.Display.DisplayModeDescription.ShadedId
display_mode = Rhino.Display.DisplayModeDescription.GetDisplayMode(shaded_id)

_
c.

1 Like