• Login
sketchucation logo sketchucation
  • Login
🤑 SketchPlus 1.3 | 44 Tools for $15 until June 20th Buy Now

Ruby Importer API Crash

Scheduled Pinned Locked Moved Developers' Forum
3 Posts 2 Posters 312 Views 2 Watching
Loading More Posts
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    Jim
    last edited by 25 Feb 2009, 21:52

    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:
    2009-02-25_164403.jpg

    But here is the result just before BugSplat:
    2009-02-25_164615.jpg

    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:


    ExampleImporter.rb

    Hi

    1 Reply Last reply Reply Quote 0
    • S Offline
      sangahn
      last edited by 27 Feb 2009, 15:39

      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!

      1 Reply Last reply Reply Quote 0
      • J Offline
        Jim
        last edited by 28 Feb 2009, 03:37

        That fixed it! Thank you, Sang. 👍

        Hi

        1 Reply Last reply Reply Quote 0
        • 1 / 1
        1 / 1
        • First post
          1/3
          Last post
        Buy SketchPlus
        Buy SUbD
        Buy WrapR
        Buy eBook
        Buy Modelur
        Buy Vertex Tools
        Buy SketchCuisine
        Buy FormFonts

        Advertisement