algorithmic modeling for Rhino
Hello, I am building a customised GH component Visual Studio (C#). I already managed to create "standard" components using the GHA assembly wizard (which is really helpful by the way!). Now, I want to add radio buttons within my component. I started from an existing script which works (using Reflector) but I can't recovred the value button cheked :( .Can you help me?
Tags:
Hi Sawsan,
this is quite difficult. If you want to change the way a component looks and responds to mouse clicks you need to override the Attributes. Problem is that component attributes are very complicated because a component is an aggregate of input and output parameters and the component itself (floating parameters by contrast are much easier to override). In fact the only overridden components in Grasshopper core are the Legend and the Gradient objects, which you'll find in the Grasshopper.Kernel.Special namespace.
Here are the steps required to do what you want:
--
David Rutten
david@mcneel.com
Poprad, Slovakia
Thank you David, This is what I have done :
1:I made component that reversing a string
2:I imported a dll karamba to make a menu of two radio buttons
I wonder if there is another simple method to recover the value of button (for example, if I understand how karamba recovred the value button cheked of its menu button) .?
here is my code you can see :/
Ah, so you want to add items to the component menu? I thought you wanted to add buttons to the component display on the Grasshopper canvas.
--
David Rutten
david@mcneel.com
Poprad, Slovakia
yes David, I want to add two radio buttons (ON / OFF)
ON to execute such program and off program will not execute.
As you can see in my code I added two buttons but when I select it does not change the program always execute. help me: (
I can't find any buttons in your code, but since you just want to extend the component menu, you can do it as follows:
private bool m_enabledState = true;
protected override void AppendAdditionalComponentMenuItems(System.Windows.Forms.ToolStripDropDown menu)
{
base.AppendAdditionalComponentMenuItems(menu);
Menu_AppendItem(menu, "Custom Enabled", Menu_EnabledClicked, true, m_enabledState);
}
private void Menu_EnabledClicked(object sender, EventArgs e)
{
RecordUndoEvent("Enabled Changed");
m_enabledState = !m_enabledState;
ExpireSolution(true);
}public override bool Write(GH_IO.Serialization.GH_IWriter writer)
{
writer.SetBoolean("EnabledState", m_enabledState);
return base.Write(writer);
}
public override bool Read(GH_IO.Serialization.GH_IReader reader)
{
m_enabledState = true;
reader.TryGetBoolean("EnabledState", ref m_enabledState);
return base.Read(reader);
}
--
David Rutten
david@mcneel.com
Poprad, Slovakia
thank you david for your help :) here is my code I made a mistake in the project I sent in early.
thank you for checking with me what 's the fault ?? and thank you again :)
Ning doesn't accept RAR files, please re-post as a ZIP.
--
David Rutten
david@mcneel.com
Poprad, Slovakia
I sent a message contains the code you find here the dll karamba
David what I want is that when I click the button "on" the program will execute when I click off it does not run.
here attached image component
Ok, so you don't want stuff in a menu, you want it on the canvas all the time. This means overriding component attributes which -as mentioned- is difficult. You need to change the way the attributes are laid out. Change the way they are drawn and change the way they respond to mouse-clicks.
I attached a combination GH_Component, GH_Attributes pair that shows some very basic attributes overriding. Hopefully it can get you started.
--
David Rutten
david@mcneel.com
Poprad, Slovakia
is there perhaps a possibility to add items to the component menu without heavy programming? there are several cluster-components I use over and over and I am tired to copy/paste them again and again from other definitions...
Welcome to
Grasshopper
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
© 2024 Created by Scott Davidson. Powered by