Continuing the discussion from Import - view all supported file types:
Just some test code to test the concept of the feature requested in the linked thread.
- MS Windows only
- Does not save paths from session to session
- Does not manipulate the individual filetype’s import settings
# encoding: UTF-8
module SomeAuthor
module ImportAllSupported
extend self
@@loaded = false unless defined?(@@loaded)
@@last_image_dir ||= ""
@@last_model_dir ||= ""
IMAGE_TYPES ||= [
'*.bmp','*.jpg','*.jpeg','*.png','*.psd','*.tif','*.tga',
].join(';')
MODEL_TYPES ||= [
'*.dae','*.ddf','*.dem','*.dwg','*.dxf','*.fbx','*.ifc','ifcZIP',
'*.kmz','*.obj','*.wrl','*.skp','*.stl','*.xsi','*.3ds'
].join(';')
def import_any_image_type
path = @@last_image_dir.empty? ? ENV['HOME'] : @@last_image_dir
filepath = UI.openpanel(
'Choose file for Import', path, "All Supported Image Types|#{IMAGE_TYPES}||"
)
if filepath
@@last_image_dir = filepath
Sketchup.active_model.import(filepath)
end
end
def import_any_model_type
path = @@last_model_dir.empty? ? ENV['HOME'] : @@last_model_dir
filepath = UI.openpanel(
'Choose file for Import', path, "All Supported Model Types|#{MODEL_TYPES}||"
)
if filepath
@@last_model_dir = filepath
Sketchup.active_model.import(filepath)
end
end
unless @@loaded
UI.menu('File').add_item('Import any Image Type...') { import_any_image_type() }
UI.menu('File').add_item('Import any Model Type...') { import_any_model_type() }
@@loaded = true
end
end
end