Ruby Importer API Crash
-
Sang Ahn has posted an introduction to the SketchUp Ruby Importer API on the SketchUp API Blog. The API allows you to put your import in the File > Importers menu, for one.
However, my simple test of the API crashes SU repeatably. Can anyone confirm the following code crashes SketchUp? If so, I'll file a bug report.
You can see the importer does appear in the correct menu:
But here is the result just before BugSplat:
Here's the code. You can see all it does is print the file:
class JfObjImporter def description # Returns a brief description of your importer plugin. "JF OBJ Importer (*.obj)" end def file_extension # Returns the file extension of the file format your # importer can read (e.g. fbx, dae, etc.) "obj" end def supports_options? # Returns true if your plugin supports import options. false end def do_options # Presents the import options dialog panel to the user. end def id # Returns the id string of your importer. "JFimporterID" end 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. p file_name IO.readlines(file_name).each do |line| puts line end end end Sketchup.register_importer JfObjImporter.new
Here's the file:
-
I left out an importer detail in the blog post.
load_file
needs a return code. Returns 0 on success, 1 on error. D'oh!
-
That fixed it! Thank you, Sang.
Advertisement