algorithmic modeling for Rhino
I copied Arend's idea of using a text file to embed code into a scripting component. This way you can use Visual Studio or any other alternative as the editor.
It works real-time, the scripting component is run every time the file is saved. The code is also stored inside the component, so if you want to send the file to someone else, you just need to send the .gh. They don't need the text file or any additional plugin.
I haven't tested it much yet.
Things not working:
- You have to type the input arguments manually if you want intellisense for them.
- If you want to add assemblies you have to do it both in the scripting component and VS and manually add the using line.
Tags:
Comment
Hey Thierry,
Just place c# componet on the circle above FiletoScript or VS2GH component (VS2GH is the new version of FiletoScript uploade bellow)
Hey. I know it is very old topic, but I've updated this component by adding Custom Usings (in previous version, custom Usings where gone with each component update.)
So now just decorate your code by:
// <Custom using>
Your usings...
// </Custom using>
// <Custom code>
Your code...
// </Custom code>
// <Custom additional code>
Your extra code...
// </Custom additional code>
Here is VS project: VS2GH.7z
Best.
Hi,
This is exactly what I'm looking for but I don't understand how to make the link between FiletoScript component and the C# script component. Could you help me?
Thank
After a bit of digging...
1)
"Index was outside the bounds of the array." Means you did not put
"// <Custom code>" and "// <Custom code>"... As mentioned... ;(
2)
I got : 1. Solution exception:[A]ScriptComponents.Component_CSNET_Script cannot be cast to [B]ScriptComponents.Component_CSNET_Script. Type A originates from 'ScriptComponents, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' in the context 'LoadNeither' in a byte array. Type B originates from 'ScriptComponents, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' in the context 'LoadNeither' in a byte array.
Type casting seemed to bother about versions I guess.
So I used dynamic conversion (Net 4.0) :
var ghc = Grasshopper.Instances.ActiveCanvas.Document.FindComponent(point);
dynamic scriptComponent = Convert.ChangeType(ghc, ghc.GetType());
instead of:
var scriptComponent = (Component_CSNET_Script)Grasshopper.Instances.ActiveCanvas.Document.FindComponent(point);
3)
ScriptComponent found in Script.gha from Grasshopper. Not really used since it dynamically casted. But might be useful for auto-completion.
Hope this could help someone.
Hi,
I'm really interested to use your filetoscript component.
But I can't make it running.
I get "1. Index was outside the bounds of the array."... From Grasshopper.
Secondly, I try to build the source and can't find where you got "ScriptComponent library".
VS can't find it. Is it from a Grasshopper DLL ?
Regards,
Hi Arend,
Did you post any code for doing something similar that I might have missed?
I didn't write anything to export back the code when new inputs are created in the scripting component.
I'm not sure if it's worth it, you'd still have to close the file in VS and open it again, as it currently is you just have to copy paste one line of code after adding the inputs.
nice! Very elegant refactor. The part of exporting new parameters is out as far as I understand?
// scriptComponent.SourceCodeChanged(new Grasshopper.GUI.Script.GH_ScriptEditor(Grasshopper.GUI.Script.GH_ScriptLanguage.CS));
super nice!
Ok, so now it works with both C# and VB. Please find the .gha here
http://www.grasshopper3d.com/group/milkbox/forum/topics/file-to-scr...
(you have to be a member of the Milkbox group)
Thank you for your detailed solution
Welcome to
Grasshopper
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
© 2024 Created by Scott Davidson. Powered by
You need to be a member of Grasshopper to add comments!