Write obj without prompting

(Victor Munyoz) #1

When I call the function DocumentParser.writeObj the prompt asks the user to “select meshing options”. How can I save an obj file without asking the user to enter this value?

(Dale Fugier) #2

Hi @victor.munyoz,

I am not familiar with this class or method. Can you provide some sample source code, that we can run here, that repeats what you are seeing?

– Dale

(Victor Munyoz) #3

I’m sorry, the function writeObj was mine…
The function is actually:

var tmpFileName = Path.GetTempFileName() + ".obj";
var script = $"_-SaveAs \"{tmpFileName}\" _Enter";
RhinoApp.RunScript(script, false);
var bytes =  File.ReadAllBytes(tmpFileName);
return bytes;

(Victor Munyoz) #4

Any idea of how to avoid the prompt when running these lines of code?

(Dale Fugier) #5

Hi @victor.munyoz,

How about this:

var script = $"_NoEcho _-SaveAs \"{tmpFileName}\" _Enter";

– Dale

(Victor Munyoz) #6

I tried the option “_NoEcho” but still the same problem.
It keeps asking to “select the meshing option (DetailedOptions PolygonDensity=50)”
Am I doing somethink wrong?

(Dale Fugier) #7

Hi @victor.munyoz,

No, you are not doing anything wrong. But you will need to provide meshing parameters in your script.

– Dale

(Victor Munyoz) #8

When this message appears, I always click Enter (I assume it selects some default parameters)
So, I tried to add an extra “_Enter” in the script, and… it works! So, the problem seems solved.
Thank you