Hi @piac ,
I am trying to somewhat replicate the Grasshopper “Explode Tree (Bang)” component with ghpython component (0.6.0.3, Rhino 5 SR12 32 bit, Grasshopper 0.9.0076).
I am looking for the same functionality that “Explode Tree (Bang)” component has, but with a two slight differences:
-
The output parameters will be automatically created, instead of manual creation used by the “Explode Tree (Bang)” component (user needs to click on the “+” sign to create).
-
The component would only create output parameters, if
_runIt
input is set toTrue
. Otherwise all output parameters will be deleted, except for the “output” one.
I have two issues:
- After the outputs are removed, the following error message emerges:
Output parameter Index[i] too high or too low for Component Python Script
It is repeated for the number of output parameters - 1 times (because I am never removing the “output” parameter).
I am not sure if it is caused by the ghenv.Component.Params.Output.RemoveRange method on line 21.
So I tried to remove the output parameters one by one instead:
#ghenv.Component.Params.Output.RemoveRange(1, numberOfOutputs-1)
outputParamsIndices = range(1, ghenv.Component.Params.Output.Count) # never include "output"
outputParamsIndices.reverse() # remove the parameters from the end
for index in outputParamsIndices:
ghenv.Component.Params.UnregisterOutputParameter(ghenv.Component.Params.Output.Item[index])
ghenv.Component.Params.OnParametersChanged()
But again the upper error message remained.
I can solve this by checking the “Do not show this message again” check box in the lower left corner. But still I would have to do this each time Rhino is restarted. It’s a bit annoying.
- Second issue is that, once output parameters are removed, the wires which connected those output parameters to the panels, remain glitchy. Here is an explanation in screenshots:
Component’s _runIt
input set to False
:
Component’s _runIt
input set to True
, and output parameters connected to panels manually:
Component’s _runIt
input set to False
. The wires remain glitchy:
Btw. the inputData
contains a tree with three branches
I would welcome any kind of help.
Component is attached below.
Thank you!
explode_tree_ghpython.gh (10.1 KB)