Hi, I want to add bool toggle
to stop the code from running when the event finished,
is that possible?
I thought about using mouse click but i don’t find an event for that.
using Rhino.Display;
using Rhino.PlugIns;
namespace RhinoToGrasshopper
{
public class RhinoToGrasshopperPlugin : PlugIn
{
public RhinoToGrasshopperPlugin()
{
Instance = this;
RhinoView.SetActive += OnViewSetActive;
RhinoView.Modified += OnViewModified;
}
public override PlugInLoadTime LoadTime => PlugInLoadTime.AtStartup;
public static RhinoToGrasshopperPlugin Instance { get; private set; }
public static string viewname;
private static void OnViewSetActive(object sender, ViewEventArgs args)
{
viewname = args.View.ActiveViewport.Name;
}
private static void OnViewModified(object sender, ViewEventArgs args)
{
viewname = args.View.ActiveViewport.Name;
}
public static void ActiveView()
{
using (var args = new Rhino.Runtime.NamedParametersEventArgs())
{
args.Set("activeview_name", viewname);
Rhino.Runtime.HostUtils.ExecuteNamedCallback("RhinoActiveView", args);
}
}
}
}
I try this but didn’t work
using Rhino.UI;
using System.Windows.Forms;
namespace RhinoToGrasshopper
{
public class MouseEvent : MouseCallback
{
public static bool toggle;
protected override void OnMouseDown(MouseCallbackEventArgs e)
{
if (e.MouseButton.Equals(MouseButtons.Left))
{
toggle = true;
}
else
{
toggle = false;
}
base.OnMouseDown(e);
}
}
}
Than i use toggle
public static void ActiveView()
{
if (MouseEvent.toggle == true)
{
using (var args = new Rhino.Runtime.NamedParametersEventArgs())
{
args.Set("activeview_name", viewname);
Rhino.Runtime.HostUtils.ExecuteNamedCallback("RhinoActiveView", args);
}
}
}
This actually works but i need a way to get MouseLeft
click Up and Down MouseUp
and MouseDown

I try another way, but didn’t work, maybe toggle == true
need to wait but i don’t know how?
Command.BeginCommand += OnBeginCommand;
Command.EndCommand += OnEndCommand;
------------------------------------------------------------------------------
private static void OnBeginCommand(object sender, CommandEventArgs args)
{
toggle = true;
commandname = args.CommandEnglishName+" begin "+toggle.ToString();
}
private static void OnEndCommand(object sender, CommandEventArgs args)
{
toggle = false;
commandname = args.CommandEnglishName+" end " + toggle.ToString();
}
------------------------------------------------------------------------------
public static void ActiveView()
{
if (toggle == true)
{
using (var args = new Rhino.Runtime.NamedParametersEventArgs())
{
args.Set("activeview_name", viewname);
Rhino.Runtime.HostUtils.ExecuteNamedCallback("RhinoActiveView", args);
}
}
}