RunScript("_NetworkSrf",true) not functioning in plugin for Rhino 8 SR15

Hi,

Running Rhino 8 SR15 here.

Developing some C# plugins with VS 2022 I have come across an issue where at least the RhinoApp.RunScript("_NetworkSrf", true); and perhaps other Runscript commands no longer appear to do anything - either during debugging or in the compiled plugin.

This code functions fine with the attached .3dm example file when run as a .cs script in script editor.

// #! csharp
using System;
using Rhino;

public class Test
{
    public static void TestMethod()
    {
        // Select all curves in the document
        RhinoApp.RunScript("_SelCrv", true);
        
        // Run the Network Surface command
        RhinoApp.RunScript("_NetworkSrf", true);  
    }
}

Test.TestMethod();

However, when the attached VS project with the command below is run,

using Rhino;
using Rhino.Commands;

namespace TestPlugin
{
    public class SurfaceTest : Command
    {
        public SurfaceTest()
        {
            Instance = this;
        }

        ///<summary>The only instance of this command.</summary>
        public static SurfaceTest Instance { get; private set; }

        public override string EnglishName => "SurfaceTest";

        protected override Result RunCommand(RhinoDoc doc, RunMode mode)
        {
            // Select all curves in the document
            RhinoApp.RunScript("_SelCrv", true);

            // Run the Network Surface command
            RhinoApp.RunScript("_NetworkSrf", true);
            return Result.Success;
        }
    }
}

All that happens is that the curves are selected, the following is printed in the command window, and the curves are unselected.

Command: SurfaceTest
Command: _SelCrv
4 curves added to selection.
Command: _NetworkSrf

Rhinocommon version of the VS project is 8.0.23304.9001.

A few weeks ago before the latest update(s), all the runscript commands in my C# plugins worked fine, whereas this is no longer the case. So, I suspect something has changed with the new version.

I gladly welcome any thoughts as to where this strange behaviour is coming from and how to resolve it.

Thanks,
Allan

Below is the Script editor code, the .3dm file and the VS project.

TestPlugin.zip (163.7 KB)
TestMWE.cs (326 Bytes)
TestRunScript.3dm (48.2 KB)

To run the RunScript() command, you likely need to apply the CommandStyle/ScriptRunner attribute to your command class:

[Rhino.Commands.CommandStyle(Rhino.Commands.Style.ScriptRunner)]

2 Likes

Thanks Jason,

That works perfectly.

1 Like