Grasshopper

algorithmic modeling for Rhino

Adding input/output parameters once on canvas much like how the C#/Python component works

Hi there.

I am interested in emulating the functionality of the Python/C# IO parameter's functionality:

On "+" or "-" you are able to remove input or output parameters.

My questions are:

1. Is this done through override the Render()?

2. I have an inkling on how this is done -- through generating the RegisterInputParams/RegisterOutputParams dynamically? 

EDIT: Oh it looks like ghPython is open sourced. I'll check out its source code then -- thanks! https://github.com/mcneel/ghpython

Views: 1166

Replies to This Discussion

Implement IGH_VariableParameterComponent in your GH_Component class and watch the magic unfold.

See: http://www.grasshopper3d.com/forum/topics/gha-developers-implementi...

--

David Rutten

david@mcneel.com

They are the same. RegisterInputParams is called only once, from within the constructor of the GH_Component class. This is where you have to setup the default parameter layout.

--

David Rutten

david@mcneel.com

You implement the IGH_VariableParameterComponent in your component class:

public MyComponent : GH_Component, IGH_VariableParameterComponent

{

    public MyComponent() : base(......){}

    // implement CanInsertParameter, CanRemoveParameter etc. here.

}

--

David Rutten

david@mcneel.com

It could be that exceptions are thrown by the new methods that GH silently handles. Can you post a GHA file that shows this behaviour?

--

David Rutten

david@mcneel.com

I can see one bug:

pManager[5].Optional = true;

You only have 5 inputs so the highest valid index is 4, not 5. This method will probably throw an indexoutofrange exception which causes the component to not even load.

If that's indeed the problem, let me know and I'll some more informative messaging.

--

David Rutten

david@mcneel.com

Incidentally, I get this error message on load:

which seems to confirm my earlier indexing bug suggestion.

--

David Rutten

david@mcneel.com

Yup, reflector.

When the discussion gets nested too deep, Ning doesn't allow further responses. It's a stupid limitation but nothing we can do anything about.

--

David Rutten

david@mcneel.com

Since we're already nested so deep, let's start a new discussion about this.

--

David Rutten

david@mcneel.com

RSS

About

Translate

Search

Photos

  • Add Photos
  • View All

Videos

  • Add Videos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service