How to Organize Components in a Compiled '.ghpy' - Python Plugin

in Order to determine place for each component, [in a Compiled .ghpy file, consisting several components], to my knowledge, there are two ways:

  1. in the script:
    ghenv.Component.Category = “Mesh” (or self.Category … )
    ghenv.Component.SubCategory = “Util”

  2. When compiling using ‘Ghpython Scripting Component’ use the menu to select, Catagory and Subcategory [ which I guess these settings will override the settings from method 1, right?]

and the Question is:
there is a subset inside each category, divide with a horizontal line (picture below)
image

how to determine each component’s place in these Subsets? (or how to draw these horizontal lines?)


@AndersDeleuran , @piac

You see, the goal of this code is to ultimately assign a category and subcategory during component creation. If it happens later, it’s still OK, but the Grasshopper SDK expects these values during the creation already: https://developer.rhino3d.com/api/grasshopper/html/730f0792-7bfb-4310-a416-239e8c315645.htm#GH_ComponentConstructor

  • If you write the component code manually, you assign these values in the constructor.

  • If you use the help of the wizard, method 2 is the fundamental method. You can see how the wizard will fill these values in the constructor if you choose to copy the compilable code that the wizard writes.

  • If you use “Method 1”, all that will happen is that the component is created with the category set in the dialog (using that same constructor functionality), and then it will be reset later during the “solve” step of the GH definition. So it will be set twice.

About that tab, it’s the Exposure property/attribute of the component that controls that. https://developer.rhino3d.com/api/grasshopper/html/P_Grasshopper_Kernel_GH_DocumentObject_Exposure.htm
See this topic: AdditionalHelpFromDocStrings for .ghpy about a way to override it.

2 Likes