Hi all ,
I’m trying to make a custom component (using C#) which is resizable, so I’m making a attribute class that inherits from GH_ResizableAttributes. It’s a bit of a struggle atm, since I’d like my component to have a input, but I can’t get it to work. By overriding the Render-function, I can draw an input grip, but I can’t use it… It’s like Grasshopper doesn’t know it’s there, even though I’ve also added the input in the component-class.
I’m thinking I might need to add something in the Layout-function too, but I can’t figure out how/what? So I would really appreciate if anyone has any inputs on this!
In my GH-component class I have;
public class MyComponent: GH_Component
………
…
protected override void RegisterInputParams(GH_Component.GH_InputParamManager pManager)
{
pManager.AddIntegerParameter(“Numbers”, “Numbers”, “Numbers”, GH_ParamAccess.list);
}
Then in my attributes-class:
public class ComponentsAttributes: GH_ResizableAttributes
protected override void Layout()
{
base.Layout();
//---- ?
}
protected override void Render(GH_Canvas canvas, Graphics graphics, GH_CanvasChannel channel)
{
base.Render(canvas, graphics, channel);
if (channel == GH_CanvasChannel.Objects)
{
GH_Palette palette = GH_Palette.Normal;
GH_Capsule capsule = GH_Capsule.CreateCapsule(Bounds, palette);
capsule.AddInputGrip(this.InputGrip);
capsule.Render(graphics, Selected, Owner.Locked, true);
}
}
1 post - 1 participant
Read full topic