But the question is, I want that when I open the ‘File --> Save As’ , the test.skp appears automatically in the File name box. How can I do it in Ruby?
The Ruby API focuses on the model/scene graph datastructures, not on fully scripting the UI (when automating things, you would usually want to automate the actions and bypass the slow UI). You cannot set the default file name in the save dialog under File → Save as….
You can however set a suggested file name when you trigger a custom file dialog. You can then either add it to the menu or create a toolbar button for it.
Something like (untested):
However consider it bad practice to save environment-specific data, like operating system specifics, device specifics, in document files (that are not configuration files).
For example if you save absolute file paths, they will file on systems with other directory layout (especially if you work on a non-unix system like Windows where drive letters can differ from one installation to another). Instead, you can savely save paths relative to the current document’s path, the current working directory or the user’s home directory (but ensure that any subdirectories exist).
But it creates a custom file dialog instance (as I wrote we can do), but it does not permanently manipulate the behavior of the native menu item File → Save as…
I guess I thought that is what the OP was asking for.
True but on MS Windows the common Save As dialog will automatically stuff the previous saved name into the Filename field. This is a OS common behavior.
If the file has never been saved then “Untitled.skp” is stuffed into the filename field.