C# module trouble with .obj export

Hi there,

I used existing code module and adapted it to export multiple .stp files and .obj files. Unfortunately the .obj export doesnt work well.

The programm is still asking me to press enter in rhino regrding the polygone mesh density of the .obj file. Is there any workaround or think which can be made easier during .obj export?

stp and obj export.gh (129.1 KB)

using System;
using System.Collections;
using System.Collections.Generic;

using Rhino;
using Rhino.Geometry;

using Grasshopper;
using Grasshopper.Kernel;
using Grasshopper.Kernel.Data;
using Grasshopper.Kernel.Types;

using System.IO;
using System.Linq;
using System.Data;
using System.Drawing;
using System.Reflection;
using System.Windows.Forms;
using System.Xml;
using System.Xml.Linq;
using System.Runtime.InteropServices;

using Rhino.DocObjects;
using Rhino.Collections;
using GH_IO;
using GH_IO.Serialization;

/// <summary>
/// This class will be instantiated on demand by the Script component.
/// </summary>
public class Script_Instance : GH_ScriptInstance
{
#region Utility functions
  /// <summary>Print a String to the [Out] Parameter of the Script component.</summary>
  /// <param name="text">String to print.</param>
  private void Print(string text) { /* Implementation hidden. */ }
  /// <summary>Print a formatted String to the [Out] Parameter of the Script component.</summary>
  /// <param name="format">String format.</param>
  /// <param name="args">Formatting parameters.</param>
  private void Print(string format, params object[] args) { /* Implementation hidden. */ }
  /// <summary>Print useful information about an object instance to the [Out] Parameter of the Script component. </summary>
  /// <param name="obj">Object instance to parse.</param>
  private void Reflect(object obj) { /* Implementation hidden. */ }
  /// <summary>Print the signatures of all the overloads of a specific method to the [Out] Parameter of the Script component. </summary>
  /// <param name="obj">Object instance to parse.</param>
  private void Reflect(object obj, string method_name) { /* Implementation hidden. */ }
#endregion

#region Members
  /// <summary>Gets the current Rhino document.</summary>
  private readonly RhinoDoc RhinoDocument;
  /// <summary>Gets the Grasshopper document that owns this script.</summary>
  private readonly GH_Document GrasshopperDocument;
  /// <summary>Gets the Grasshopper script component that owns this script.</summary>
  private readonly IGH_Component Component;
  /// <summary>
  /// Gets the current iteration count. The first call to RunScript() is associated with Iteration==0.
  /// Any subsequent call within the same solution will increment the Iteration count.
  /// </summary>
  private readonly int Iteration;
#endregion

  /// <summary>
  /// This procedure contains the user code. Input parameters are provided as regular arguments,
  /// Output parameters as ref arguments. You don't have to assign output parameters,
  /// they will have a default value.
  /// </summary>
  private void RunScript(List<Brep> Geom, string FilePath, string Filename, bool Bake, ref object A)
  {

    string Filename2;
    RhinoDoc rd = RhinoDoc.ActiveDoc;

    //Rhino.FileIO.File3dm f = new Rhino.FileIO.File3dm();
    //f.Polish();


    if(Bake)
    {
      var number = 0;
      foreach(Brep b in Geom)
      {

        Filename2 = Filename + "_" + number;
        string pFullPathName = Path.Combine(FilePath, Filename2 + ".stp");
        string pFullPathName2 = Path.Combine(FilePath, Filename2 + ".obj");
        number++;

        switch(b.ObjectType)
        {
          case ObjectType.Brep:
            rd.Objects.AddBrep(b);
            break;

          default:
            break;
        }

        //STEP
        System.Threading.Thread th1 = new System.Threading.Thread(ThreadWork);

        th1.Start();
        Rhino.RhinoApp.RunScript("_-Save " + "\"" + pFullPathName + "\" ", false);


        //OBJ
        System.Threading.Thread th2 = new System.Threading.Thread(ThreadWork);

        th2.Start();

        Rhino.RhinoApp.RunScript("_-Save " + "\"" + pFullPathName2 + "\"  ", true);

        //Note - the GH script pauses here due to a waiting input process on the RhinoApp side.. it won't see lines after this until the user does something.
        //Is there a way to append the save command with the needed information on Step Schema so it does not pop-up the input in the first place. Or perhaps
        //a hard coded method that does not need to use the RhinoApp class and can carry out the save completely from GH? Maybe licencing forbids it from being
        //exposed throuh Rhino API?
        //Rhino.RhinoApp.RunScript("@\n", true);
        //Rhino.RhinoApp.RunScript("_Enter", false);
        //RhinoApp.SendKeystrokes("", true);
      }
      //f.Write(pFullPathName, 5);
      //f.Dispose();
    }





  }

  // <Custom additional code> 
  static void ThreadWork()
  {
    System.Threading.Thread.Sleep(1500);
    Rhino.RhinoApp.SendKeystrokes("", true);


  }

  /// <summary>
  /// This method will be called once every solution, before any calls to RunScript.
  /// </summary>
  public override void BeforeRunScript()
  { }
  /// <summary>
  /// This method will be called once every solution, after any calls to RunScript.
  /// </summary>
  public override void AfterRunScript()
  { }

  // </Custom additional code> 
}