Button and context menu options on component through GhPython

That’s awesome! Would that mean we can override DrawViewportMeshes and DrawViewportWires now? And if so, could you maybe provide a small example of how, pretty please :slight_smile:

Yes, both are true. An example can be found in this post.
Now that GhPython is distributed with Rhino 6 and 6 has shipped, this becomes more useful.

2 Likes

Ah yes, of course, that takes me back. This really is terrific. Great job guys :clap:

2 Likes

I “cannot import componentbase from ghpythonlib” - does this only work with Rhino 6?

Yes, this is a Rhino 6 feature.

Come on Guilio, tell the secret how to put the button there :slight_smile:

EDIT: I really think it makes little sense to use time to make a button there… sorry.

Thanks,

Giulio


Giulio Piacentino
for Robert McNeel & Associates
giulio@mcneel.com

Well I have v6 :wink:

Pretty please a button.
Reason being, I’m too much of a programming noob to be able to use the API properly. I end up trial and error Rhino.something() does it require an argument does it not?!

Why do you want to do this?

I want to create a script acting like a switch, with button on it.
when you click on the button it cycles through the inputs

Edit: and/or the outputs, preferebly it could be two buttons one cycling through the inputs and other through the outputs (that is you have only one output variable but different data (formula) is provided(calculated) depending on the button click.)

This, really, can be easily done with the dropdown example above. If @DavidRutten sanctions UI change to button and provides a sample, I’ll gladly translate it to Python for you.

Use case 2: (or more of a UC1 2nd alternative solution)

2018-05-29%2000_07_54-Greenshot

This is a thread I created not long ago about the same topic:
https://discourse.mcneel.com/t/ghpyhon-access-to-grasshopper-gui/62240

I can’t help you out with Python, but if you want to create objects with a custom appearance special mouse handling then you’ll need to switch from Python to Visual Studio and create a GHA project. Then you can override the attributes of your components and parameters (as per the example in the developer documentation, downloadable via the GH Help menu).

I think David is right; while possible in Python, if you really want to go for the button, it is better if it is done in Visual Studio with C# because of autocompletion and also because there is the tutorial in the Grasshopper SDK docs, written by him, regarding Custom Attributes (C#).

Thanks,

Giulio


Giulio Piacentino
for Robert McNeel & Associates
giulio@mcneel.com

A post was split to a new topic: Handle/update the checked state of a menu item

Dear Giulio Piacentino, with this method, is there a way to save the user’s selection in a gh/ghx file, next time when user open the file, it’s last chosen option rather than the default one.

In that case one can be inspired by this code which looks like is the same as in the karamba library:

1 Like

We have the same problem

Is there a way to solve this problem? I also encountered the same problem

Hello,

I just found out I was quoted in this post. We also isolated in a github repository the UI widgets from Karamba3d - with permision of the creators, in case someone wants to use them for their own C# plug-ins:

1 Like