Custom Component UI OutputGrip

Hi guys,

Does anyone happen to know how to set the position of the output grip and Name correctly in a custom Component ? Also how to remove the jagged edge if there’s no inputs ? Any help would be much appreciated. I have shared part of the code here
Untitled

class Custom_Attributes(Grasshopper.Kernel.Attributes.GH_ComponentAttributes):
    def __init__(self, component):
        self.component = component

    def Layout(self):
        super(Custom_Attributes, self).Layout()

        rec0 = copy.copy(self.Bounds)
        rec0.Height += 25
        rec0.Width += 80
        self.m_innerBounds = rec0
        
        rec1 = copy.copy(rec0)
        rec1.Y = rec1.Bottom -20
        rec1.X = rec1.Left + 15
        rec1.Height = 20
        rec1.Width = 100
        rec1.Inflate(-2,-2)
        self.ButtonBounds = rec1
        self.ButtonShine = 1
        self.Bounds = rec0

Thanks !

I don’t known with Python but in C# you could assign by your own the m_innerBounds protected field and use it to layout parameters using
https://developer.rhino3d.com/api/grasshopper/html/M_Grasshopper_Kernel_Attributes_GH_ComponentAttributes_LayoutInputParams.htm
https://developer.rhino3d.com/api/grasshopper/html/M_Grasshopper_Kernel_Attributes_GH_ComponentAttributes_LayoutOutputParams.htm
and get the Bounds with:
https://developer.rhino3d.com/api/grasshopper/html/M_Grasshopper_Kernel_Attributes_GH_ComponentAttributes_LayoutBounds.htm

This is how GH renders the lack of parameters so to avoid this you have to replace the render method and replicate all the capsule rendering except that. But I would not do this and respect the original design.

2 Likes

It worked out! Looks better now, thanks @Dani_Abalde