I’m stranded making on the code of the Event Handler. I would like to know whether or not any C# component is changed on the active campus. Thanks to the several topics on this forum, I could make the code below, but it doesn’t work although the IntelliSense of Rhino8 allows it. Does anyone point out which part is wrong?
// Grasshopper Script Instance
using System;
using System.Collections;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using Rhino;
using Rhino.Geometry;
using Grasshopper;
using Grasshopper.Kernel;
using Grasshopper.Kernel.Data;
using Grasshopper.Kernel.Types;
public class Script_Instance : GH_ScriptInstance
{
/*
Members:
RhinoDoc RhinoDocument
GH_Document GrasshopperDocument
IGH_Component Component
int Iteration
Methods (Virtual & overridable):
Print(string text)
Print(string format, params object[] args)
Reflect(object obj)
Reflect(object obj, string method_name)
*/
private void RunScript(ref object a)
{
if(!_init)
{
Component.ObjectChanged -= CSharpChangedHandler;
Component.ObjectChanged += CSharpChangedHandler;
_init = true;
}
a = guid;
}
private bool _init = false;
private bool a = false;
Guid guid = new Guid();
private void CSharpChangedHandler(IGH_DocumentObject sender, GH_ObjectChangedEventArgs e)
{
if (e.Type == GH_ObjectEventType.Enabled && sender.Name.Contains(“CSharp”))
{
guid = sender.InstanceGuid;
Component.ExpireSolution(false);
}
}
}