generative modeling for Rhino
I have a very fundamental question about GH for which I can't find the answer. Is it possible to capture the script created in GH as a code. If so, what are the code languages and how could it be done? I know that VB and C# codes could be brought into GH and used, but I don't know if the opposite process is also possible.
I would appreciate any help.
Well, you can select everything in your GH definition, copy it and then paste it to any text editor. You would get a bunch of XML code that represents the definition you put together. Whatever you do with that from there on is up to you! ;)
there is no single script running behind the scenes. A Grasshopper definition consists of a runtime database of instantiated types which are defined in a collection of .NET assemblies. There is no restriction on what language was used to create those assemblies, though VB.NET and C# are the only ones I use.
When you copy a set of components, an xml string is put in the clipboard which is identical to (well, very similar) a ghx file. It does not contain any of the logic of the components, merely which ones are hooked together.
Thanks for response. Yes, I am interested in a way to capture and transfer the logic in some code language to be integrated with a more complex tool. I don't know how to write VB or C#, but I was hoping there is a way to export the GH definition as a code that conveys the logic.
My suggestion would be that you try some other platform. There's just no way you can transfer all the logic running inside a Grasshopper file to a stand-alone executable. You'd have to provide mirror images of the Grasshopper SDK, the RhinoCommon SDK and the Rhino SDK. And then of course if you're dealing with 3rd party components you might get into even more referenced assemblies, some of which are copyrighted.
The only way to run the logic embedded in Grasshopper gh/ghx files is to run them through Grasshopper.
Mmmm...you can code using Microsoft Visual Studio instead using standar c# and vb components inside GH. The editor is better and you get lot of new tools to develope your own code ;)
This tool will generate C++, C# and VB code for you, just point it to your xml or schema. Try your GH code and let me know, it should work.