Assign content of an txt-file to a variable without windows dialog box


#1

Hi,

I’ve created with MATLAB a txt-file in which I imported some Rhino commands. Now I want to read this txt-file with RhinoScript and run the commands in Rhino. Therefore I use the command openfilename. My Problem is, that i have to choose the txt-file in a Windows Dialog box. Is there a way to get the commands automatically, without choosing the txt-file in a Dialog box?
A similar Problem I have at the part where I want to save a stp-file. Furthermore my stp-file is always empty. Where is my mistake.
I added the script in the attachment.

I appreciate your help.

Best regards
Felix

Mat2Rhino.rvb (820 Bytes)


#2

Hi @Felix2, to read directly from the text file, just replace this line:

strFileName = Rhino.OpenFileName("Open", "Text Files (*.txt)|test.txt|")

with something like this, so you give a valid path to the text file directly:

strFileName = "C:\MyTextFile.txt" 

For your second problem, it would be helpful to see the commandline output in Rhino. You can look at this output if you let Rhino.Command print to the command line like this:

Rhino.Command "-_Export " & filename & " _enter", True

_
c.