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.newHere's the file:
-
I left out an importer detail in the blog post.
load_fileneeds a return code. Returns 0 on success, 1 on error. D'oh!
-
That fixed it! Thank you, Sang.

Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better π
Register LoginAdvertisement