RespondToButton error?

Hi,

I’m trying to make my own analysis component.

Thanks to your support on Forum, I succeeded to make radiobutton and receive boolean into solver.

However, I found that there is still some problem.

As you see in my .gif, buttons are linked between another component.
I want to solve them but I don’t know how to fix it.

Does anyone know how to do that?

Best,
Shimpei

There’s little we can do without seeing the code.
But it seems that you are sharing the same IGH_Attributes instance between components (copies, maybe?) or some field of it. Or maybe you overridden some functionality incorrectly.

Are you doing this in the GH_Component?

void CreateAttributes(){
   m_attributes = new MyCoolAttributes(this);
}

Hello Dani_Abalde,
Thanks for the reply.

I’m sorry I forgot writing my script.

I’m using this in the GH_Component

public override void CreateAttributes()
{
    m_attributes = new Attributes_Custom(this);
}

It’s okay. I can’t help you without see code.

Much like @Dani_Abalde I don’t have omnipresent vision either. Best I can do is ask whether you’re using static variables in your classes.

1 Like

David

yes, I’m using static variable in my component to give and receive boolean between solveinstance and attributes class.

Static variables can be shared between components?
If can be, error will be happened as you said…

Static fields do not belong to the instance but to the class, so you are accessing the same space in the memory from different instances. To access the GH_Component from the attributes, you can use the Owner property and convert it to your data type, or create a field within the IGH_Attributes.
Something like:

public class MyAtt : GH_Attributes<MyComp>{
  MyComp comp;
  public MyAtt(MyComp owner) : base(owner){
    comp = owner;
  }
}

Not ‘can be’, are.

Static fields are shared amongst all instances of a class and I think its derived types as well.

David,

In that case,I think I have to change the way to contain boolean.

I read this topic you replyed.

I couldn’t find where boolean container be mentioned.(GH_IWriter and IReader? I don’t know…)

Could you tell me where should I refer in your code?
TestFile.cs (5.0 KB)

Hi Shimpei, just curious if you would be willing to share your source code, at least the GUI drawing and interacting portions?

I’m sure there are quite a few people around (myself included) who would like to develop simple plugin components with buttons and checkboxes, and would be really grateful for a reference implementation to save the trouble of figuring it out from scratch :slight_smile:

(And also it would be much easier to help you to troubleshoot)

Thanks to everyone, finally I’ve improved my component!

I’m using property instead of static class.

Thanks for your support!!!

Best regards,
Shimpei

Hi qythium,

I think my code and explanation is poor, so you should refer this topic.

This topic is very helpful for you to make custom attribute class such as making buttons on component.

Thanks - I’ve read that forum link before, but the example given there was somewhat rough around the edges -
image
I was perhaps hoping for a more complete copy-and-paste implementation especially for the radio buttons, without having to dive into learning GDI drawing syntax :sweat_smile: