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_actionreturnstrue, 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
21933I do not know if there is a cross-platform string arg.
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better đź’—
Register LoginAdvertisement