Hi,
I want to make some buttons just like Karamba component in C#.
Here attaches is Karamba component image that I want to make.
Does anyone know how to script it in C#?
Best,
Shimpei
Hi,
I want to make some buttons just like Karamba component in C#.
Here attaches is Karamba component image that I want to make.
Does anyone know how to script it in C#?
Best,
Shimpei
You have to override the attributes of your component and do all the additional drawing/layout/mouse-handling there. It’s not easy, but there’s a small example in the Grasshopper SDK documentation (down via the GH Help menu).
Hello David,
Thank you for letting me know about attribute class!
In addition,How do I call a circle (dot) on the image?
I want to search it on SDK.
Best,
Shimpei
Graphics.FillEllipse()
Hi David,
I was able to modify attribute in my component.
However, I couldn’t understand MouseRespond class.
Only I understood is to show MassageBox.
I want to receive ‘true or false’ data from checkbox on the component and reflect it to SolveInstance.
Can you give me something example code ?
Here attached is my .gha file.
MyProject1.gha (11 KB)
I would LOVE to be able to define UI components inside a cluster and “export” them to the surface of the cluster. Then drag to re-arrange them…
Hi Shimpei,
Not sure if you have fixed your issue already, but it seems there was a problem in your code.
Where you had:
public override GH_ObjectResponse RespondToMouseDown(
GH_Canvas sender,
GH_CanvasMouseEvent e)
{
if (e.Button == MouseButtons.Left && (RectangleF) this.CircleBounds0.Contains(e.CanvasLocation))
{
int num = (int) MessageBox.Show("Button0", "respond test", MessageBoxButtons.OK);
return GH_ObjectResponse.Handled;
}
.....
.....
return GH_ObjectResponse.Handled;
}
The input for your Contains method should be in ints. Also make sure that you return GH_ObjectResponse.Ignore when not clicked, hovered etc. Otherwise, dragging your component might be impared.
public override GH_ObjectResponse RespondToMouseDown(
GH_Canvas sender,
GH_CanvasMouseEvent e)
{
if (e.Button == MouseButtons.Left && this.ButtonBounds.Contains((int) e.CanvasX, (int) e.CanvasY))
{
int num = (int)MessageBox.Show("\"Select Excel\" button clicked.", "Button clicked", MessageBoxButtons.OK);
return GH_ObjectResponse.Handled;
}
return GH_ObjectResponse.Ignore;
}