I used to do something like this, but if there is a direct way to call rhino common export methods I would also be quite interested… Maybe there are also smarter ways to react to the errors by raising exceptions or so…
protected void ExportSat(List<Brep> breps, string path)
{
List<Guid> guidList = new List<Guid>();
Rhino.DocObjects.Tables.ObjectTable ot = Rhino.RhinoDoc.ActiveDoc.Objects;
for (int i = 0; i < breps.Count; i++)
{
if (breps[i] == null || !breps[i].IsValid)
{
this.AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "No object to bake, or brep not valid, aborted.");
return;
}
System.Guid guid = ot.AddBrep(breps[i]);
guidList.Add(guid);
}
int nSelected = ot.Select(guidList);
if (nSelected != guidList.Count)
{
this.AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "Not all objects could be selected, aborted.");
return;
}
string cmd = "-_Export " + path + ".sat" + " _Enter";
Rhino.RhinoApp.RunScript(cmd, false);
ot.Delete(guidList, true);
}