Grasshopper

algorithmic modeling for Rhino

Hi I have a component with variable number of inputs and outputs.

I am going to need the names of the inputs in my workflow, and therefore to launch an event that raises when the name of the input has been changed by the user. 

I attach an image and code showing the following behavior:

  • VariableParameterMaintenance() does not run on changing of the nickname of inputs, but runs if something else is changed afterwards. 

Additionally, I would appreciate any help on how to add behavior to a component when double clicking on it.

Thank you very much

Manuel

Views: 1194

Attachments:

Replies to This Discussion

Hi,

for the double click following solution works:

public override Grasshopper.GUI.Canvas.GH_ObjectResponse RespondToMouseDoubleClick(Grasshopper.GUI.Canvas.GH_Canvas sender, Grasshopper.GUI.GH_CanvasMouseEvent e)
{
  if (Owner != null)
  {
  ////Your CODE////
  return Grasshopper.GUI.Canvas.GH_ObjectResponse.Handled;
  }

  return Grasshopper.GUI.Canvas.GH_ObjectResponse.Ignore;
}
  public override bool HasInputGrip
  {
  get
   {
   return false;
   }
  }
}

Ha.

That did no work either. Both Methods retrieve an error, "... no suitable method to override"

Is there anything that i have to inherit in my component class??

The variable Owner in the firs method does not exist in my code. Is it maybe in a grasshopper namespace that I havent explicitly included??

Thank you very much To]

ok, so for the double click you need a attribute class before the component


public class GH_Component_"YOURCOMPONENT"Attributes : Grasshopper.Kernel.Attributes.GH_FloatingParamAttributes
{
public GH_Component_"YOURCOMPONENT"Attributes(GH_Component_"YOURCOMPONENT" Owner) : base(Owner) { }

///// the overide from before/////
}

an in the component class


public override void CreateAttributes()
{
m_attributes = new GH_Component_"YOURCOMPONENT"Attributes(this);

}

Thanks to]

I go for it.

Sorry to]

I don't get it to work. Apparently owner is not a valid parameter for base constructor.

It should be of Grasshopper.Kernel.IGH_Param type instead of GH_Component.

I tried with the different types under IGH_Param, but it rather wants an instance than the type itself

Sorry to]

Thank you very much

Hi Manuel,

this are working code snippets but of course you have to adapt it to your example.

good luck

Haha.

Sorry to]

I was also already ashamed of asking again

Thanks a lot

for the nickname add following function:

void GH_Component_AddAttributes_ObjectChanged(IGH_DocumentObject sender, GH_ObjectChangedEventArgs e)
{
   if (e.Type == GH_ObjectEventType.NickName)
   {
      ExpireSolution(true);
   }
}

Hi To.

This has not worked. I am a bit lost though. I dont know wether there should be any other attribute in the class or something that is in there is wrong.

Actually the SolveInstance is not even working when the component is instantiated on the canvas. Maybe it is not an issue, as actually there is going to be always an event before running the SolveInstance Method.

Thanks

PS.  Actually not. I just connected a slider and disconnected and changed the values on it and it does not trigger the VariableParameterMaintenance() method

Thanks to]

I ll try that

RSS

About

Translate

Search

Videos

  • Add Videos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service