sketchucation logo sketchucation
    • Login
    ℹ️ Licensed Extensions | FredoBatch, ElevationProfile, FredoSketch, LayOps, MatSim and Pic2Shape will require license from Sept 1st More Info

    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

      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

        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

          That fixed it! Thank you, Sang. 👍

          Hi

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

          Advertisement