Grasshopper

algorithmic modeling for Rhino

I have been messing around with custom parameters over the past couple days and I seem to have run into a limitation I cant pass. I would like to add more than one input utilizing mouse clicks on a component. The problem I have is when I attempt to inherit more than one type of GH_Param at the begining of my class. Is it not possible to add additional inputs or am I approaching the problem the wrong way?

-Steve

Views: 673

Replies to This Discussion

"I would like to add more than one input utilizing mouse clicks on a component"


I don't understand what this means. Please elaborate.


--

David Rutten

david@mcneel.com

Poprad, Slovakia

Sorry I didn't mean to be so vague. I have currently developed a component with only one output, a GH_Boolean which responds to a double click on the component and proceeds to open an external program if there are no instances of that program and closes it if the program is currently running. 

Now I would like to prompt the user to save the file in a location prior to closing the program. It seems now after I reevaluate my code that the initial Inherits statement declares output parameters. I have uploaded my code so hopefully my post is easier to understand. 

My question now becomes is it possible to have more than one output in a component with custom parameters?

Attachments:

Ok so what you have is a class that derives from GH_Param(Of GH_Boolean) which provides it's own attributes. So as long as you keep this object as a stand-alone it will work. But once you put the object into a component as an input or output, your attributes will be replaced by special attributes and the double-clicking behaviour will go away.

Am I right so far?

Also, you have not "developed a component with only one output", what you have done is create a new type of parameter, which always only has a single input/output. If you want to use this parameter from within a component, you'll need to derive a class from Grasshopper.Kernel.GH_Component instead, and register your StartProgram parameter as an input or output.


It is possible to create your own objects that have multiple inputs and or outputs but it is very difficult. You are highly advised to stick to GH_Component. You can still override the Attributes (as I do with the Gradient and Legend objects) and thus provide custom painting or clicking behaviour.


Can you make a sketch of the exact object you're trying to create? Napkin will do.


--

David Rutten

david@mcneel.com

Poprad, Slovakia

Attached is the component I have thus far. If I understand you correctly then having a string output, in addition to the boolean output already defined in the program, is not possible unless I derive the class from GH_Component.

Attachments:

The biggest problem is that any individual attribute can only have a maximum of one input and one output. Components solve this by actually being a conglomerate of attributes. You could use the same trick, but it would involve a lot of coding. If you build your object as a GH_Component, then you get all that stuff for free. 

You can still override display and mouseclicks on components (VB and C# components for example override the double click, Gradient overrides the display, the layout, mousedown, mousemove and mouseup).

In your GH_Component derived class, override CreateAttributes() and assign your own attributes, just as you're doing now. However, in this case derive your attributes not from GH_Attributes(Of StartProgram) but from Grasshopper.Kernel.Attributes.GH_ComponentAttributes.

--

David Rutten

david@mcneel.com

Poprad, Slovakia

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