TIG:
Not used to Ruby's Escape char yet. Didn't have one in VB.
Eric_Erb:
Made several attempts at a solution. Ended up by chaining the following tools
- Windows File Types setting (A process launched when double clicking a file)
- RubyScriptLauncher.exe (My New Executable)
- Ruby template file (textbased)
- SketchUp
The end result is relatively quick and close to what you asked for. The only thing I can think of that might be an issue is that you can only import one file at a time and that it launches a new copy of SketchUp each time you use it.
I found one unexpected bug with my program this morning so I will not be uploading it until tonight when I get home and fix it.
I wrote the program to be non-specific.
It may be used with any file type that Sketchup can import through the SketchUp API.
You control what happens via the information you plug into the Windows File type settings and a the Ruby template file. You can have multiple template files for different import file types. My program uses the template file to construct a ruby file in plugins before starting Sketchup. After Sketchup is running and the file is imported the ruby file is automatically deleted.
Both the program and the template file must be located in the SketchUp PlugIns folder.
--- template file Auto_Import_DWG.TXT example ---
` # TEMPORARY_RUBY_FILENAME = Auto_Import_DWG.rb
The comment line above is required. Use any name you like for the .rb file.
model = Sketchup.active_model
show_summary = false
status = model.import "INSERT_FILENAME_TO_IMPORT_HERE", show_summary
In the line above the string "INSERT_FILENAME_TO_IMPORT_HERE" must exist.
It is case sensitive
layers = model.layers
Turn on all imported Layers
layers.each do | layer |
layer.page_behavior = LAYER_VISIBLE_BY_DEFAULT
layer.visible = true
end
view = model.active_view
view.refresh
view.zoom_extents
All comment lines and empty lines are removed when the ruby file is created.
Feel free to add whatever ruby code you want to run.`
--- end template file Auto_Import_DWG.TXT example ---
--- Windows File Type Information example ---
Application to perform this action:
"C:\Program Files\Google\Google SketchUp 7\Plugins\RubyScriptLauncher.exe" "%1" "Auto_Import_Dwg.TXT"
(Note the double quotes around each piece of information.)
If you need help getting to and setting up the Windows File Type settings for DWG let me know.