Hi, I’m fairly new to Rhino development so excuse me if this has already been asked.
I’m trying to write C# code that saves the current document to an .obj format, but I don’t want to have any user input necessary. I’d like to be able to specify or automatically provide all options necessary. Currently, there are a number of prompts in the methods I have tried.
2.) Best to surround path strings with double-quote characters (just in case the path string contains spaces).
3.) Make sure to save to a folder that you have rights to save in.
A quick example:
protected override Result RunCommand(RhinoDoc doc, RunMode mode)
{
var path = Environment.GetFolderPath(Environment.SpecialFolder.Desktop);
path += "\\test.obj";
// Make sure to surround filename string with double-quote characters
// in case the path contains spaces.
var script = string.Format("_-SaveAs \"{0}\" _Enter", path);
RhinoApp.RunScript(script, false);
return Result.Success;
}
Use path = Path.Combine(path, "test.obj"); to make it work on Macs too. Now you are hard-coding the backslash directory separator; Path.Combine will respect the forward slash on other platforms than Windows.