Monday, February 23, 2009

SketchUp Importers

There's a lot of 3D content out there, and we understand that a lot of it is not in the SketchUp file format. But, if you can read the content, you can use the Ruby Importer plugin API to import it into SketchUp.

It's easy to write and use your own Ruby importers in SketchUp. Just follow these steps:

1. Define a class with the plugin API methods.
2. Register an object of the class with SketchUp.
3. Recover from Mardi Gras festivities (may not be applicable).

An importer class must have the following methods:

def description
  # Returns a brief description of your importer plugin.

def file_extension
  # Returns the file extension of the file format your
  # importer can read (e.g. fbx, dae, etc.)

def supports_options?
  # Returns true if your plugin supports import options.

def do_options
  # Presents the import options dialog panel to the user.

def id
  # Returns the id string of your importer.

def load_file(file_name, show_summary)
  # Reads the contents of location on disk specified
  # by file_name.
  # Shows the summary dialog panel if show_summary is true.
  # Returns 0 on success, returns 1 on failure.

Once you have defined your importer class, register your importer with SketchUp:


Now your importer plugin will be available when you select the Import item under the File menu of SketchUp. The Ruby Importer capability is available in both SketchUp Free and Pro. Now go forth and import.

No comments: