Auto-Generating Python Pins

Hey everyone,

My python3 workflow in GH still involves the tedious process of right-clicking pins, renaming them, and manually setting type hints for every new script.

The C# component and certain AI-gen plugins can generate their inputs and outputs onto the canvas automatically.

How can I can do this with the native Python 3 / Script Editor in Rhino 8. Cannot find a single example

1 Like

What do you mean by a pin? An input or output Param? A search for the latter will find how-tos for the old GHPython components. They’re just using the Rhino and Grasshopper APIs though. Python3 has access to those too.

Yes, the input and out params.

I found those threads but those where more like a “hack” to force the old Python component to act like a dynamic C# component. Seem unnecessarily complex and will likely cause more headaches than it solves.

Could findn’t anything related to the new Script Editor nor CPython

according to Gemini this should work, but it doesn’t

#! python 3

# input: list Point3d test_pts

# output: list Curve test_crv

Converting the python script to a GH_ScriptInstance will give you similar behaviour to C#

great, had no idea.
But how to define the out Params?

auto_gen.gh (3.0 KB)

#! python 3
import Rhino.Geometry as rg
import Grasshopper

class MyComponent(Grasshopper.Kernel.GH_ScriptInstance):

    def RunScript(self, ab: float, cd: list[bool], ef: Grasshopper.DataTree[object]):

        status = "Success"

        return status