+ Reply to Thread
Results 1 to 5 of 5

Thread: Grasshopper python component suggestion

  1. #1
    Super Moderator Mitch's Avatar
    Join Date
    May 2010
    Location
    Switzerland
    Posts
    288

    Grasshopper python component suggestion

    I don't know if this is the right place to post this...

    It would be nice if the editor window also had fields for managing the inputs and outputs, it's kinda annoying to have to right click 3 times, once to set the inputs, once to set the outputs and once to open the editor... Otherwise, I love this thing...

    Thanks, --Mitch

  2. #2
    Hi Mitch,
    the next version of the GhPython component uses the updated Zui features in Grasshopper.
    You will be able to zoom-in and click the "+" and "-" signes.
    Thanks for bringing this up
    - Giulio
    _________________
    giulio@mcneel.com

  3. #3
    Super Moderator Mitch's Avatar
    Join Date
    May 2010
    Location
    Switzerland
    Posts
    288
    Hi Giulio,

    OK, thanks! Couple of other things -

    1) Once you put your own script in there, the component can't distinguish from no input, insufficient input or incorrect input. With normal GH components, the first two result in an orange component color, the last with a red. With GHPython it's always red until it's correct. I would like to see the component be orange when one or more inputs are disconnected, don't know if that's possible.

    2) I would like to be able to prompt the user as what the component is expecting at the inputs and and returning at the outputs - right now all you have is "Script variable X..." , but the standard components give you the actual description of the data it is expecting - so that would imply in the input/output manager would have a place to type in these names, and then they could show up when someone hovers the mouse over the spot.

    3) Relative to the above, if a type hint (such as "curve") is given for any input, that the input right click generic "set one data item" changes to the type specific "set one curve"...

    Thanks, --Mitch
    Last edited by Mitch; 05-13-2012 at 02:07 PM.

  4. #4
    Senior Member Steve Baer's Avatar
    Join Date
    Apr 2010
    Location
    Seattle
    Posts
    1,464
    Blog Entries
    19
    Hi Mitch,
    I added these latest set of requests as wishlist items to the ghpython issue tracker
    https://github.com/mcneel/ghpython/issues/37

    Thanks,
    -Steve

  5. #5
    Hi Mitch

    thank you for further specifying your needs. Here my thoughts about these items.

    1) If I understand this correctly, it's not really the (GhPython) component: it's how all components work in Grasshopper. It is not just about the color: also the message text is important. The detection of component needs is delegated to the coder. By default the component is just gray, as there are no messages. The GhPython component additionally gives a message when there is "no code". Then, the orange color is up to you as a developer: if you want to achieve it, you need to add a warning and a message to the component. The following code provides an example:

    Python Code:
      from clr import AddReference
      AddReference('Grasshopper')
      import Grasshopper.Kernel
       
      if x is None:
          w = Grasshopper.Kernel.GH_RuntimeMessageLevel.Warning
          ghenv.Component.AddRuntimeMessage(w, "I was expecting a x value!")

    If you exchange Warning with Error, you can obtain a red color. Just like the orange color is associated with some warning, the red color is usually just associated with the idea of error, but not especially with inputs or functionality. The GhPython component additionally catches exceptions and shows them as a red message. That's handled for you, in case you forgot to check the inputs or something bad happened. But best practice would be that you as a coder avoid the exception with defensive coding practices.

    2) Yes. Right now all a user knows is the 'Type hint' and the 'Nickname' you associated to the inputs. There is a nice suggestion to modify the input 'Description' though DocStrings. https://github.com/mcneel/ghpython/issues/31 Essentially, the component would do this:

    Python Code:
      ghenv.Component.Params.Input[1].Description = "The description for the second input"

    but in the form of Python DocStrings within the code editor.

    3) This would take some modifications to the Grasshopper scripting parameters. Right now this is exactly the same behavior as in the rest of the scripting components (C#, Vb.Net), as the same classes are used. But I can see this would be nice. I'll try to let David know...

    Thanks,
    - Giulio
    ________________
    giulio@mcneel.com
    Last edited by Giulio Piacentino; 05-15-2012 at 07:41 PM. Reason: improved spellings

+ Reply to Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts