RhinoApp.Runscript not working in C# script from toolbar

I am trying to use RhinoApp.Runscript inside a C# script.

When I hit the ‘Run’ button inside the ScriptEditor, it works perfectly.
However I would like to assign the script to a toolbar button, with the macro

-ScriptEditor _run “myscript.cs”

Then the script fails. Probably the command ScriptEditor should be a ScriptRunner command for it to work ?

Is there another way to execute a C# script from a toolbar button ?

Hi @i-Shape,

Make sure to full path the script file.

For example:

_-ScriptEditor _Run "C:\Users\Dale\Downloads\example.cs"

– Dale

Hi Dale,

Sorry if my question was not clear. The correct path was not the problem.

I meant there is a ‘RhinoApp.Runscript’ statement inside the C# script, which fails to execute when the script is run from a macro. Like in the simplified example script below.

So I repeat my question, how could I assign this C# script to a toolbar button ?

using System;
using System.Diagnostics;
using Rhino;

int radius = 100;
bool sts = Rhino.RhinoApp.RunScript($“-Circle 0,0,0 {radius}”, true);
if (sts)
RhinoDoc.ActiveDoc.Views.Redraw();

Thanks in advance

This bug report applies to Python 3 scripts, also.

Calls to RhinoApp.Runscript work when run from the IDE, but fail when the same script is run from the command line.

This applies to Python 3 , Rhino 8.3 running on Windows computer.

If the echo parameter for RhinoApp.Runscript function is set to True the code will echo the script component’s text to the command line but the Function itself returns False and fails to execute.

RhinoApp.Runscript functions seem to work fine in IronPython when running them using RunPythonScript in Rhino 8.3.

@i-Shape, @jim,

I’ve logged the issue so we can look into what you’ve reported.

https://mcneel.myjetbrains.com/youtrack/issue/RH-79530

Thanks,

– Dale

RH-79530 is fixed in Rhino 8 Service Release 4 Release Candidate