Retrieve import file name?
-
Is there some way to retrieve the "File -> Import..." file name that the user selects in the Import Browser? Perhaps some observer would have access to that name?
My goal is to import a dxf file into Sketchup, and then run a script that parses that dxf text file, to obtain more information from it. I cannot use "model.import" directly though, because the user must have access to the Options dialog in the Import Browser. Also, Sketchup.send_action(21112) does not work for me. Even though send_action returns true, no Import Window appears.
-
Since you have
filepath=UI.openpanel(...)
The imported file is
filename=File.basename(filepath)
If an importer doesn't append the file-type then use
filename=File.basename(filepath, ".*")
However, the name isn't 100% guaranteed as there might be a similar existing component's name so
filename=model.definitions.unique_name(filename)
which will give the one that will be used... -
@lestercavey said:
Also,
Sketchup.send_action(21112)
does not work for me. Even thoughsend_action
returnstrue
, no Import Window appears.Because the API Dictionary is way out of date, and that list of integers is erroneous.
The proper integer (PC only,) to invoke the "File > &Import..." is
21933
I do not know if there is a cross-platform string arg.
Advertisement