Modify Python Script to Ignore Groups and Scribble from Selected Objects

You can also change the code in order to control wire display of objects in a group:

from Grasshopper.Kernel import GH_ParamWireDisplay
from Grasshopper.Kernel import GH_RuntimeMessageLevel 
from Grasshopper.Kernel import Special
# A dictionary of wire types 
wire_display = [GH_ParamWireDisplay.default, GH_ParamWireDisplay.faint, 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')

    objects = []
    for i in range(len(sel_objs)):
        if type(sel_objs[i]) is Special.GH_Group:
            objects.extend(sel_objs[i].Objects())
        else:
            objects.append(sel_objs[i])

    for obj  in objects:
        if hasattr(obj, 'Params'):
            for p in obj.Params.Input:
                p.WireDisplay = wire_display[wire_type]
        elif hasattr(obj, 'WireDisplay'):
            obj.WireDisplay = wire_display[wire_type]

Wire.gh (21.4 KB)

3 Likes