[c#] Keep selected points selected from plugin command

Hello, I’m currently fiddling with the sdk. Here is the snippet of my C# plugin

using System;
using Rhino;
using Rhino.Commands;
using Rhino.DocObjects;
using Rhino.Input;
using Rhino.Input.Custom;

namespace MyProject3
{
    [System.Runtime.InteropServices.Guid("74b72927-0cd4-41a0-a0b4-6794579896a5")]
    public class Hello : Command
    {
        public override string EnglishName
        {
            get { return "csPickPoint"; }
        }

        protected override Result RunCommand(RhinoDoc doc, RunMode mode)
        {
            Rhino.RhinoApp.RunScript("SelPt", false);
            return Result.Success;
        }
    }
}

So basically when I enter csPickPoint on the command, it will select all points on my rhino 3d, just like what SelPt command does. But then, as soon as I entered csPickPoint on command, all points get selected -> and less than 1 sec it will get deselected.

How do I keep them selected? Anyone can give me pointers?
Thank you very much!

bump*

in case anyone got confused what I’m trying to do here is, basically I want csPickPoint do exactly what SelPt does, but keep the selected points stay selected. Because the way I figure it, it seems that right after

 Rhino.RhinoApp.RunScript("SelPt", false);

This got executed, the points got deselected.

You won’t find many people reading this forum on the weekends, especially not over summer holidays in Europe :smile:

The problem is that if you want to run scripts from your command, you need to add an attribute to the command to enable this: [CommandStyle(Style.ScriptRunner)]

    [System.Runtime.InteropServices.Guid("74b72927-0cd4-41a0-a0b4-6794579896a5")]
    [CommandStyle(Style.ScriptRunner)]
    public class Hello : Command
    {
        public override string EnglishName
        {
            get { return "csPickPoint"; }
        }

        protected override Result RunCommand(RhinoDoc doc, RunMode mode)
        {
            Rhino.RhinoApp.RunScript("SelPt", false);
            return Result.Success;
        }
    }
1 Like

Thank you, work super!