-import get filename import

I´m using RhinoApp.RunScript("_Import", false) to import a file

How could I get the name of the imported file?

Hi Salva,

Rhino does not save the file path somewhere, but it usually reports it to the commandline. You might try the suggestion here and then validate the result before using it.

c.

Hi @clement, thanks for your answer.

I´ve been looking at your solution, but my application is multilingual, and I think I should program a different solution for each language and I would not like to do it.

for line in lines:
        a = line.find("File") 
        b = line.find("successfully read")
        if a > -1 and b > 5:
            file = line[a+6:b-2]
            break

I have Rhinoceros in Spanish and the line is “El archivo xxxxxxxx.dxf se ha importado correctamente”, but some clients have Rhinoceros in English or German and I suppose that this line is different.

other idea?

Well you could get the locale ID using:

Rhino.ApplicationSettings.AppearanceSettings.LanguageIdentifier

and then keep track of the proper command line entries. Alternatively, instead of using:

RhinoApp.RunScript("_Import", false) 

is there a reason why you do not you use a proper file open dialog which returns the filename and filepath ?
I mean something like this:

filename = rs.OpenFileName("Open", "dxf Files (*.dxf)|*.dxf||")
if filename: 
    rs.MessageBox(filename)
    # import the file using Rhino.Command...

I´m asuming you are asking the user to pick a file of course.

c.

1 Like

This is good. Thanks.