Change Wire Display: Custom Preview: M Input

Hi guys,

I found this Python code to change wires of selected componets so kindly provided by Atelier Panda on this page.
http://pandagopanda.com/thoughts/2014/7/28/meta-grasshoppering-i-cleaning-up-wires

from Grasshopper.Kernel import GH_ParamWireDisplay
from Grasshopper.Kernel import GH_RuntimeMessageLevel 

# A dictionary of wire types 
wire_display = {'0':GH_ParamWireDisplay.default, 
                '1':GH_ParamWireDisplay.faint,
                '2':GH_ParamWireDisplay.hidden}

# Get selected components and change the wire display
if on:
    doc = ghenv.Component.OnPingDocument()
    sel_objs = doc.SelectedObjects()
    if not len(sel_objs):
        ghenv.Component.AddRuntimeMessage(GH_RuntimeMessageLevel.Warning, 'Nothing was selected')
    for sel_obj  in sel_objs:
        if not hasattr(sel_obj, 'Params'): continue
        for p in sel_obj.Params.Input:
            p.WireDisplay = wire_display[wire_type]

I might be just needing one more step of specification, I would like to change specifically all M inputs on the Custom Preview component.

I have been taking a look at the Grasshopper SDK but I could’t find any reference to selecting specific inputs of components…

Thanks for any insight,
Shynn

Hello, it is old topic but maybe this help someone,

from Grasshopper.Kernel import GH_ParamWireDisplay
from Grasshopper.Kernel import GH_RuntimeMessageLevel 
import Grasshopper as gh

wire_display = [GH_ParamWireDisplay.default,
GH_ParamWireDisplay.faint,
GH_ParamWireDisplay.hidden]

objects = ghenv.Component.OnPingDocument().Objects
for obj in objects:
    if obj.Name == "Custom Preview":
        if on:
            for input in obj.Params.Input:
               input.WireDisplay = wire_display[wire_type]

Thanks for the update! I am very new to grasshopper and I am not very sure how to get this working. Can you please elaborate a little bit more on how I could make use of this script and connect(?) to the object that I wish to preview in wireframe? And what should I expect as an outcome of this? Thank you once again!

This use to change wire display of all components, it is not for objects.

wire.gh (2.7 KB)

For object display use this:

1 Like

Thank you so much for your reply! Very clear and concise!