sketchucation logo sketchucation
    • Login
    Oops, your profile's looking a bit empty! To help us tailor your experience, please fill in key details like your SketchUp version, skill level, operating system, and more. Update and save your info on your profile page today!
    πŸ«› Lightbeans Update | Metallic and Roughness auto-applied in SketchUp 2025+ Download

    Newbie switching active models

    Scheduled Pinned Locked Moved Developers' Forum
    3 Posts 2 Posters 223 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.
    • T Offline
      Travis_K
      last edited by

      I am trying to create a set of thumbnails (600px x 600px) for several thousand .3ds files by importing each file then write a image. I can create a thumb for a single .3ds file without any difficulties. However when I try to batch the process sketchup will not switch the focus from the first imported model and all resulting thumbnails are identical to the first image / model.

      Any help would be much appreciated!

      #######################################
      require 'sketchup'
      Sketchup.send_action "showRubyPanel:"

      def import_3ds(file)
      model = Sketchup.active_model
      model.import file, false
      m_def = model.definitions
      location = Geom::Point3d.new 0,0,0
      entities = Sketchup.active_model.active_entities
      instance = entities.add_instance m_def[0], location
      thumb = file.gsub "3ds", "jpg"
      view = model.active_view.zoom_extents
      view.write_image thumb, 600, 600, true
      entities.erase_entities entities[0]
      model.close_active # this will return false
      end

      UI.menu("PlugIns").add_item("Create Thumb") {
      Dir.glob("C:/models/3ds/*.3ds") do |file|
      import_3ds(file)
      end
      }

      1 Reply Last reply Reply Quote 0
      • thomthomT Offline
        thomthom
        last edited by

        @travis_k said:

        model.close_active # this will return false

        What are you trying to do with this? Close the model?
        That's not what the method does. From the manual: http://code.google.com/apis/sketchup/docs/ourdoc/model.html#close_active

        @unknownuser said:

        The close_active method is used to close the currently active (open) group or component.

        How are you doing this batch process?

        @travis_k said:

        ... sketchup will not switch the focus from the first imported model...

        What focus? You operating with multiple windows?

        Thomas Thomassen β€” SketchUp Monkey & Coding addict
        List of my plugins and link to the CookieWare fund

        1 Reply Last reply Reply Quote 0
        • thomthomT Offline
          thomthom
          last edited by

          Ah! I see now how the batch process is.

          Still don't understand what you mean by focus though.

          Maybe calling Sketchup.file_new before each import will work? http://code.google.com/apis/sketchup/docs/ourdoc/sketchup.html#file_new

          Thomas Thomassen β€” SketchUp Monkey & Coding addict
          List of my plugins and link to the CookieWare fund

          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