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!
    🛣️ Road Profile Builder | Generate roads, curbs and pavements easily Download

    Select By Layer

    Scheduled Pinned Locked Moved Developers' Forum
    1 Posts 1 Posters 447 Views 1 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.
    • E Offline
      ezt
      last edited by

      Here is a script for selecting items in a particular layer.

      @unknownuser said:

      #Make sure this ruby file is loaded

      ("require" will load a file only if it is not loaded yet)

      require "sketchup.rb" #Make sure this ruby file is loaded

      def select_by_layer
      # First get a list of all of the layers in the model
      model = Sketchup.active_model
      layers = model.layers
      names = layers.collect {|l| l.name}

        # Display a dialog to pick the layer to select
        prompts = ["Layer"]
        values = [names[0]]
        enums = [names.join("|")]
        results = inputbox prompts, values, enums, "Select By Layer"
        return if not results
        
        # Now select everything on the selected layer
        layername = results[0]
        do_select {|e| e.layer.name == layername}
      

      end

      define our file name so we will know when we load it twice

      filename="selectbylayer.rb"

      #run this code the first time this script is loaded
      #If it is loaded again, file_loaded!(filename) will return true
      if !file_loaded?(filename)
      # get the SketchUp plugins menu
      plugins_menu = UI.menu("Plugins")
      # add a seperator and our function to the "plugins" menu
      if plugins_menu
      plugins_menu.add_separator
      plugins_menu.add_item("Select By Layer") { select_by_layer}
      end
      # Let Ruby know we have loaded this file
      file_loaded(filename)
      end

      This shows the layers in the model as a drop down list and the items selected are those in the layer chosen from the drop down list.
      What I would like is the layers to be shown in a list with checkboxes. The selected items would then be defined as all those in the layers where the boxes are ticked.

      Is this do-able? Can anyone tell me how?

      Many thanks in advance.

      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