Open / Save / Export from RhinoApp.RunScript in Rhinocommon


Hi All,

Sorry if its been answered but I cant find anything that solves my issue.
I can run all sorts of rhino commands from Runscript


If I pass a string, filename “c:\testfile.3dm” to runscript as follows

RhinoApp.RunScript("-_Open "+filename,false);


string script = string.Format("_-Import “{0}” _Enter", filename);
Rhino.RhinoApp.RunScript(script, false);

as suggested by Dale, here

the result is a command line showing [Open] then a carriage return and then nada.

If I pass the above construct (script or openfile string) to ClipBoard and then ctrl+v it into rhino its works fine…

any clues?


did you set set attribute for your class ?


Yes. Other runscript commands work. All except open save and export.

(Menno Deij - van Rijswijk) #4

Just to clarify, if you paste the exact strings of the commands into the command line (as a user), do they work?

Because if I paste _-Open "C:\temp\test.3dm" into my commandline it works and the file is opened. Same for _-Import "C:\temp\test.3dm" _Enter. Both commands also work if I run them from a ScriptRunner command.


Correct. If I copy the exact command to the clipboard and then paste it, it works, but when i run it from Scriptrunner it spits Open onto the the command line then nothing else.

My header for the plugin as follows

and my code section calling it

when i hit ctrl+v the codes runs fine, but the output from the Runscript leaves only
on the command line, nothing else.

All the other rhino commands I run this way work fine, and I use several, the only ones that don’t are related to file operations.

the content of the string fwiw is C:\Users\chris.IJM\Desktop\Untitled.3dm

plugin running :


Are you using spaces in your file location?


as per post ahead of yours, this is the content of the file string



Your runscript ends with a False, This means you dont want anything to be displayed in your commandbar.
Put it on true.


no difference on true or false, i set it to false as the only example i coudl find by Dale says to set it to false. see original post.

however here is sample output using true (same output as false)

notice the Open… then nada… when i hit ctrl-v the exact same string opens just fine


only example i can find. before anyone else asks, using double quotes or not using them, same result, pre-formatting the string, or not pre-formatting it, same result.

(Menno Deij - van Rijswijk) #11

You need to set the [CommandStyle(Style.ScriptRunner)] on the command class, not on the plug-in class. I see in your screenshot that it is now applied to PanelDock, but not to the 7 other classes. It’s also unclear if these classes are commands.

Then when you apply it to a command class, you can call scripts from the command code (which runs inside the RunCommand(RhinoDoc doc, RunMode mode) part).


When i try that i get an error that the command is not valid inside a class. Open the example by Dale above you will see the same structure. The command is just before the class. Ill post the error it spits once im at a pc. Again. As it is now many many other Runscript commands i use do work. Its only file related ones that dont.


the only place it allows me to enter this is on the initial entry, as per Dales example. anywhere else it spits the dummy.


From your previous screenshot it looks like you’re trying to open a zipped file (*.7z).
I think this is not possible. If you enable feedback Rhino should report that.

(Menno Deij - van Rijswijk) #15

it should be done like this:

[CommandStyle(Style.ScriptRunner)] // <-- put the attribute at the class level
public class MyNewCommand : Command
    static MyNewCommand _instance;
    public MyNewCommand()
        _instance = this;

    ///<summary>The only instance of the MyNewCommand command.</summary>
    public static MyNewCommand Instance
        get { return _instance; }

    public override string EnglishName
        get { return "MyNewCommand"; }

    protected override Result RunCommand(RhinoDoc doc, RunMode mode)
        string filename = @"D:\\temp\\test.3dm";
        RhinoApp.RunScript(String.Format("_-Open {0}", filename), false);
        return Result.Success;

(Menno Deij - van Rijswijk) #16

I think he has a plug-in that supports opening .7z files, at least that’s what it looks like on the Youtube video.


Hmm, looks more like compressing the actual 3DM file manually. But if it really is a zip/unzip plugin it should be an Import/Export Plugin and not a command plugin. Maybe that’s the problem then… but I doubt. No idea…

Sorry I did not read the whole thread carefully. Now I see there are classes to compress and decompress…
If the file to open will be decompressed before feed into the _Open command it should work.


my app unzips it and passes the unzipped file to the command. i just quickly did that to explain how its not actually passing the command, at all. doesn’t work for 3dms either


correct the command style is before the class, and if you read the thread you will see i have done it like that, as per dales example. no go. using true or false as the suffix.

anyhow, this thread not moving forward, ill write the open code myself, since none exists in rhinocommon and passing the command into a class that isn’t the ONLY class seems not to work.

Does anyone know if its possible to output the current file in rhino as an OBJ stream without using rhino save routines (ie read the current file into a memory and convert to obj in the stream (the way it can be done with Helix) so that I can pass it directly to my encrypter/decrypter app?

then i dont need to bother screwing around with rhino’s quirky lack of open and close operations in rhinocommon.

(Steve Baer) #21

Have you tried the exact code sample that @menno posted above?