Select By Layer
-
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)
endThis 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.
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