Grasshopper

algorithmic modeling for Rhino

Hello,

I'm writing my first GH plugin in C++ / CLI.

The compilation process is correct, it is renamed .dll by .gha and setting the path with GrasshopperDeveloperSettings.

But when running Grashopper the new command does not appear in the GH tool tabs.

However, if implemented as a C# project everything works fine.
Is there any special issue or configuration for generate GH plugin in C++/CLI?
My code and configuration is attached.


Ben Sitler warned

"Grasshopper is a DotNET plugin for Rhino, and any addition to Grasshopper must be written with VB.NET or C#.NET (Actually any DotNET language would work and even C++ or CLI would be technically feasible, but these alternative routes would be a BIG headache). David uses both C#.NET and VB.NET, and I will show you how to view existing components in either language to learn the syntax and methods of implementation. It is only a matter of preference between the two as to which one you use. To get started you are going to need to obtain some software:"

// .h
using namespace System;
using namespace Grasshopper::Kernel;

public ref class MyGhComponent : public GH_Component
{
public:
MyGhComponent ();
virtual property Guid ComponentGuid { Guid get() override; }
virtual void RegisterInputParams (GH_InputParamManager^ pManager) override;
virtual void RegisterOutputParams(GH_OutputParamManager^ pManager) override;
virtual void SolveInstance (IGH_DataAccess^ DA) override;
};

// .cpp

MyGhComponent::MyGhComponent()
: GH_Component("MyFirstComponent", "MFC", "My First C++/cli component", "Extra2", "Simple")
{
}

Guid MyGhComponent::ComponentGuid::get()
{
return Guid("{E798108C-BA7A-41b2-A69E-FB51166A1264}");
}

void MyGhComponent::RegisterInputParams(GH_InputParamManager^ pManager)
{
pManager->Register_StringParam("String", "S", "String to revert", GH_ParamAccess::item);
}

void MyGhComponent::RegisterOutputParams(GH_OutputParamManager^ pManager)
{
pManager->Register_StringParam("Reverse", "R", "String reversed");
}

void MyGhComponent::SolveInstance(IGH_DataAccess^ DA)
{
// TODO
}


// My C++/cli config page



// The C# Version

Thanks!!!

Views: 2415

Replies to This Discussion

I don't know enough about C++/CLI to provide support. I think the only person in the world who does know enough about using C++/CLI within Rhino to answer any questions would be Steve Baer, and he probably doesn't know enough about Grasshopper. 

What bit-depth is your C++ project using? C# would be bit-depth agnostic unless you override that setting, but with C++/CLI you'll need to supply a dll with the same bit-depth as the Rhino version you're running in. If that doesn't solve it I'm all out of ideas...

--

David Rutten

david@mcneel.com

Poprad, Slovakia

I know enough about grasshopper's plug-in architecture to make a guess:)

Fran, it looks like your settings are correct for loading a C++/CLI DLL into the 32 bit version of Rhino 5.  You may want to try running "GrasshopperDeveloperSettings" and uncheck the "Memory Load *.GHA assemblies..." checkbox.

I wouldn't really recommend using C++/CLI for you GHA since that requires a certain bit depth for the end user (and I have come to strongly dislike C++/CLI in Visual Studio, but that's another story.)  I would recommend instead writing a C# GHA component and if you need access to code written in C++, then use pInvoke from your C# code to call into a C++ DLL.

Could you tell me what it is you are trying to do? If you are trying to move some functionality in your plug-ins into Grasshopper, then I have a different technique that I would recommend.

Thanks,

-Steve

You may want to try running "GrasshopperDeveloperSettings" and uncheck the "Memory Load *.GHA assemblies..." checkbox.

Ok!, That's work!. Thank's Steve!!

hey,guy ,this is really cool,could you please share this with me?i really enjoy C++,thank you for you kindness.

Python - Grasshopper Component (I have tried to make a grasshopper component with IronPython, but I could not)

Is this possible to make a GH component with python? Any idea?

RSS

About

Translate

Search

Videos

  • Add Videos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service