Grasshopper

algorithmic modeling for Rhino

I tried to implement a self written .dll (VB.NET) in Grasshopper Python and got following error.

Runtime error (ArgumentTypeException): HelloWorld() takes exactly 1 argument (0 given)

 

In my mind the HelloWorld function should need no argument but return the string “Hello World”.

Help on method-descriptor HelloWorld

 |  HelloWorld(...)

 |          HelloWorld(self: MyClassLibrary) -> str

 

Can anybody help?

  

Sourcecode MyClassLibrary.vb:

  • Simple Class Library Project in Visual Studio 2015

  • Function has no parameters and Returns String „Hello World“

  • Compiled *.dll works fine in other Visual Studio Projects as reference

Project Properties

Checkbox „COM Interop“ has no impact

Views: 630

Attachments:

Replies to This Discussion

Hi Clemens,

that function (in VB) is not static, so it's an instance method.

In turn, instance methods need a "self" instance in Python. You need to first instantiate MyClassLibrary() by calling its constructor...

ghw_instance = ghw()

#then
ghw_instance.HelloWorld()


Alternatively, you could mark the method as static.

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

Hi Giulio,

thanks for your quick answer and help! Now the method works.

Clemens

RSS

About

Translate

Search

Videos

  • Add Videos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service