Hi everyone,
I have been using this Python Script to manage wire display in GH. I usually always use Default, as David manifested many times, hiding wires is no ideal. Despite this, I sometimes have to deal with definitions that have ALL wires hidden, yes globally, thanks to a VB script.
The cool thing about the Python script is that lets me revert wire display locally, (only selected objects).
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 hasattr(sel_obj, 'Params'):
for p in sel_obj.Params.Input:
p.WireDisplay = wire_display[wire_type]
else:
sel_obj.WireDisplay = wire_display[wire_type]
It has one flaw though.
Runtime error (MissingMemberException): âGH_Groupâ object has no attribute âWireDisplayâ
Traceback:
line 20, in script
When you select a group, it fails completely. Same happens with a Scribble.
I have been trying to add conditionals to the IF statement, but I in this past 2 hours I was not able to find out the proper methods to test whether an object is a group or not.
Can someone point me to the correct documentation?
I first went here and nothing was useful.
âRhinoScriptSyntax in Pythonâ link that takes you to an article that does not have the Rhino Script Syntax API anywhere not a link to it. I had to google ârhino script syntaxâ to get there.
Regarding Grasshopper, it was all a pain:
Grasshopperâs link to its API is nowhere to be found except the one and only
While in here, there are no Python examples, its all C# and VBâŚ
Then, where is the documentation that explains all the name spaces??
There is:
Grasshopper.Kernel
Grasshopper
ghpythonlib.components
Least but not least, what is ghenv??
I would greatly appreciate anyone that can clarify these concepts for me.
Shynn.





