Grasshopper

algorithmic modeling for Rhino

Dear GHA developers,

Hopefully in a few days Grasshopper 0.9.0050 will be released. The last two hurdles (the installer and assembly version rolling) are now working so once I'm certain there are no other serious bugs we're good to go.

Although there are plenty of potentially breaking changes to the SDK, I'm boldly assuming that (almost) none of them will affect your typical GHA library. If this is not the case I'll do my best to try and add some legacy support for features that have changed soon after the initial release.

There are however a few new things that you probably should support. In this discussion I'll outline several of them. Some of these are already in the current release.

Views: 5482

Replies to This Discussion

GH_AssemblyInfo

Every GHA plugin should have one (and only one) class with a public empty constructor which implements Grasshopper.Kernel.GH_AssemblyInfo. This class provides the user (and Grasshopper core) with the details regarding the plugin. It should have -at minimum- a proper Name, Id, Icon, Version and AuthorName. For example, a typical implementation of GH_AssemblyInfo could look like:

public class CurveComponentsInfo : Grasshopper.Kernel.GH_AssemblyInfo
{
  public override string Description
  {
    get { return "Provides components for curve creation, manipulation and analysis"; }
  }
  public override System.Drawing.Bitmap Icon
  {
    get { return CurveComponents.Properties.Resources.CurveComponentLibrary; }
  }

  public override string Name
  {
    get { return "Curve Components"; }
  }
  public override string Version
  {
    get { return "1.0.0.0"; }
  }
  public override Guid Id
  {
    get { return new Guid("{B76F8D3F-A2D4-46C5-8524-D076CAA50E21}"); }
  }
  public override string AuthorName
  {
    get { return "Robert McNeel & Associates"; }
  }
  public override string AuthorContact
  {
    get { return "http://www.grasshopper3d.com"; }
  }
}

Providing a proper Assembly info class means your plugin will be correctly and recognizably displayed in the Grasshopper interface.

--

David Rutten

david@mcneel.com

Poprad, Slovakia

David,

Are these requirements still valid? I note the different language for the GUID (ie. public override Guid ComponentGuid vs public override Guid Id).

For some reason this language change (Guid Id) causes errors "XXX does not implement inherited abstract member 'Grasshopper.Kernal.GH_DocumentObject.Component.get'.

Also items such as AuthorContact return an error: "no suitable method found to override".

Developer Team,

Will SVG graphics be supported for icons in future releases? It would be a nice addition!

GH_LoadingAttribute

There is a new class called Grasshopper.Kernel.GH_LoadingAttribute which allows GHA developers to specify the loading logic for their plugin. This attribute can only be assigned to assemblies, for example:

in VB     <Assembly: GH_Loading(GH_LoadingDemand.ForceDirect)>  

in C#     [assembly: GH_Loading(GH_LoadingDemand.Default)]

GH_LoadingDemand has 3 values you can pick:

  • Default        (this means the loading is the same as it would have been)
  • ForceCOFF   (this means the GHA will be loaded into memory first)
  • ForceDirect  (this means the GHA will be loaded directly off the disk)

If you do not add this assembly attribute, then Default is assumed. Note that the user can override the loading demand of a specific GHA, so all this attribute does is provide a suggestion.

For example, the image below shows that Starling will be loaded via the memory no matter what the starling developer wanted and no matter what the Grasshopper default setting is:

Furthermore, the actual loading method that was used is available via the Grasshopper banner. Open the banner via Help->About, unfold the plugin grid and double click on the plugin you're interested in:

--

David Rutten

david@mcneel.com

Poprad, Slovakia

Tab Display

Tabs can be displayed in different styles and modes in 0.9.0050. By default all tabs will still work, but it is recommended you provide additional details in case your GHA defines one or more non-standard Tabs.

You should at least provide an icon for the tab, and you can also provide short names. For example Starling and Hoopsnake install two tabs called "Sl" and "Extra" respectively. These tabs will appear as follows in the new display modes.

Normal:

Short Names:

Icon Mode:

To supply custom icons and/or shorter names for tabs, you can call the following methods:

Grasshopper.Instances.ComponentServer.AddCategoryShortName("Extra", "Ex")

Grasshopper.Instances.ComponentServer.AddCategorySymbolName("Extra", "E")

Grasshopper.Instances.ComponentServer.AddCategoryIcon("Extra", Some16x16Image)

These methods should ideally be called from the PriorityLoad() method of a GH_AssemblyPriority derived class.

This is totally optional btw. Grasshopper will provide default icons and shorter names which may well be what you wanted anyway.

--

David Rutten

david@mcneel.com

Poprad, Slovakia

Rhino Installer Engine

Grasshopper 0.9.0050 will be using the Rhino Installer Engine. It will also search for GHA files in all other folders created by the Rhino Installer Engine. We're still working on making it possible to install a GHA without an RHP using *.rhi, hopefully more news on that soon.

If you can get away with not using some heavy-weight installer package like Wise or MSI, we recommend switching to RHI.

--

David Rutten

david@mcneel.com

Poprad, Slovakia

I'm probably missing something really obvious, but where do I find the Grasshopper dlls now? My previous version of Grasshopper I had the DLLs in the Rhino Plugins folder.  Now with the installer (which was easy, thanks), I do not know where to look for DLLs for my references.

Thanks,

Mitch

Hey - this question can be ignored now.  I found the dlls finally in the AppData Roaming library after backing up from the Grasshopper Special Folder -> Components folder.  I will reference these DLLs in my Visual Studio projects.  

Grasshopper is now installed into %appdata%\McNeel\Rhinoceros\5.0\Plug-ins

you can type that uri into windows explorer (with the "percent appdata percent") and it will take you to the correct place.

--

David Rutten

david@mcneel.com

Poprad, Slovakia

Runtime messages

It is now possible to add runtime messages with the Remarks flag. Also, runtime messages are now compared to existing messages so the same message appears only once. If you don't want this you'll have to prefix your message text with an index or something.

--

David Rutten

david@mcneel.com

Poprad, Slovakia

Hi David, one but only one whish...

will i have code completion for Lambda expressions and the System.Linq extensions in the c# component? I found some snippets for this in the www ... It really helps coding.

thanks

I've switched to the latest version of QWhale Editor.NET so if they support it it will work. If not, then not.

--

David Rutten

david@mcneel.com

Poprad, Slovakia

RSS

About

Translate

Search

Photos

  • Add Photos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service