Class: Sketchup::Importer
- Inherits:
-
Object
- Object
- Sketchup::Importer
- Defined in:
- lib/sketchup-api-stubs/stubs/Sketchup/Importer.rb
Overview
The Importer interface lets you build your own importers for SketchUp. To use this, you create a subclass of Importer and implement all of the methods described below. This will make your importer appear in the list that users see under File > Import, and you can use Ruby to do all of the work of opening the file and creating whatever you need inside SketchUp.
Here is an example of a complete script that imports a .txt file and displays its contents in a messagebox.
Constant Summary collapse
- ImportCanceled =
Constants
nil
- ImportFail =
Stub value.
nil
- ImportFileNotFound =
Stub value.
nil
- ImportSuccess =
Stub value.
nil
Instance Method Summary collapse
-
#description ⇒ Object
This method is called by SketchUp to determine the description that appears in the File > Import dialog’s pulldown list of valid importers.
-
#do_options ⇒ Object
This method is called by SketchUp when the user clicks on the “Options” button inside the File > Import dialog.
-
#file_extension ⇒ Object
This method is called by SketchUp to determine a single file extension is associated with your importer.
-
#id ⇒ Object
This method is called by SketchUp to determine a unique identifier for your importer, typically something like “com.sketchup.importers.dxf”.
-
#load_file(file_path, status) ⇒ Object
This method is called by SketchUp after the user has selected a file to import.
-
#supports_options? ⇒ Boolean
This method is called by SketchUp to determine if the “Options” button inside the File > Import dialog should be enabled while your importer is selected.
Instance Method Details
#description ⇒ Object
This method is called by SketchUp to determine the description that appears in the File > Import dialog’s pulldown list of valid importers.
Though it is common for the description to include the file extension supported by the importer (such as “Text Importer (.txt)”), the actual extension is defined in the file_extension method.
90 91 |
# File 'lib/sketchup-api-stubs/stubs/Sketchup/Importer.rb', line 90 def description end |
#do_options ⇒ Object
This method is called by SketchUp when the user clicks on the “Options” button inside the File > Import dialog. You can use it to gather and store settings for your importer.
Only applicable if the importer supports options, meaning its supports_options method returns true.
108 109 |
# File 'lib/sketchup-api-stubs/stubs/Sketchup/Importer.rb', line 108 def end |
#file_extension ⇒ Object
This method is called by SketchUp to determine a single file extension is associated with your importer. Only files that match this extension will be shown to the user as they browse their harddrive for things to import.
Ruby importers are only allowed to support a single extension.
125 126 |
# File 'lib/sketchup-api-stubs/stubs/Sketchup/Importer.rb', line 125 def file_extension end |
#id ⇒ Object
This method is called by SketchUp to determine a unique identifier for your importer, typically something like “com.sketchup.importers.dxf”.
139 140 |
# File 'lib/sketchup-api-stubs/stubs/Sketchup/Importer.rb', line 139 def id end |
#load_file(file_path, status) ⇒ Object
This method is called by SketchUp after the user has selected a file to import. This is where you do the real work by opening the file via Ruby’s File object and processing it in whatever way you need.
You must return an integer success code to SketchUp when you are done. These are the codes that SketchUp understands:
- Sketchup::Importer::ImportSuccess
- Sketchup::Importer::ImportFail
- Sketchup::Importer::ImportCanceled - SketchUp will show a "cancelled" dialog
- Sketchup::Importer::ImportFileNotFound - SketchUp will show a "not found" dialog
171 172 |
# File 'lib/sketchup-api-stubs/stubs/Sketchup/Importer.rb', line 171 def load_file(file_path, status) end |
#supports_options? ⇒ Boolean
This method is called by SketchUp to determine if the “Options” button inside the File > Import dialog should be enabled while your importer is selected.
186 187 |
# File 'lib/sketchup-api-stubs/stubs/Sketchup/Importer.rb', line 186 def end |