@DavidRutten, I’ve seen examples of ScriptComponents exposing SourceCode
but it seems that GrassHopper.GUI.Script.GH_ScriptEditor doesn’t expose them anymore?
Fig1. Example :
Edit: OK, the property GetSourceCode do exist, but, I can’t cast the variable to a known valid type.
I have also seen examples of using a library named
… which seems to contain a type ("
Component_CSNET_Script")which I cannot access without that library. Another example:
var scriptComponent = (Component_CSNET_Script)Grasshopper.Instances.ActiveCanvas.Document.Find… ;
Difficult this for a newbie on .NET. So how can I retrieve the source code from a (C# or VB.Script) Script Component? I understand that I could retrieve the serialized xml for the component, but I don’t know how to get myself a valid reader for the call comp.Read(reader).
This is what I’ve so far at a breakpoint (a valid script component “
comp” dynamic cast to “
c”, but the type shown in the debog panels is not available in code, so I can’t access the ScriptSource property… ) :
Another example of that I have a paused execution on the correct type of (script) component, which I unfortunately cannot cast properly :