Grasshopper

algorithmic modeling for Rhino

I know Python won't run inside Grasshopper, but since the new Grasshopper SDK works with RhinoCommon, can I just write new components with IronPython? Or is that a ridiculous notion?

Views: 539

Replies to This Discussion

You can write components in any language that compiles to a clean .NET assembly.

--
David Rutten
david@mcneel.com
Poprad, Slovakia
What is a clean assembly? Is it one that doesn't rely on other assemblies?

I found a couple discussions that might clarify:
http://stackoverflow.com/questions/561509/how-do-i-create-a-net-ass...
and
http://stackoverflow.com/questions/579272/instantiating-a-python-cl...
These make it sound like no, but my lack of knowledge about language dependencies, the .NET framework and libraries leaves me unsure.

Maybe I should just try it.
By "clean" I meant something that works purely within the .NET framework. It is in fact possible to write Grasshopper plugins that use unmanaged dlls, but as long as you stay within .NET you can be sure that it will work.

I don't know if IronPython code can be compiled into a dll (gha).

--
David Rutten
david@mcneel.com
Poprad, Slovakia
Hmm. I think this would be a good question for Mr. Baer.

But it's not looking that good (quoted from here):
How do I compile .py files to a DLL for linking into my C# or VB program?
IronPython does not support building DLLs for a C# style of linking and calling into Python code. You can define interfaces in C#, build those into a DLL, and then implement those interfaces in Python code as well as pass the python objects that implement the interfaces to C# code.
That looks pretty bad indeed. I think Steve was working on a Grasshopper component with the IronPython runtime embedded so it wouldn't have to compile. Steve is currently at a tradeshow though so he won't be able to respond.

One thing I do know is that Steve has been able to solve pretty much every problem McNeel has thrown at him so far so I hardly think it's a question of possibility but rather a question of availability.

--
David Rutten
david@mcneel.com
Poprad, Slovakia
That's good news. Also, the RhinoCommon SDK has an Execute method on the PythonScript class, which passes on whatever is returned by the script. If I could find a way to pass arguments in to the method, then I think I could basically make a vb.net wrapper that called on a python script. Maybe tomorrow I'll try to just call a Python module from a GHA and return the Python output to Grasshopper.
Just tried this,
but VS seems to think that Execute() is not a member of Rhino.Runtime.PythonScript, though listed in the RhinoCommon SDK.
Oh well. I'll update this if any news comes up.

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