LoopLab Help
-
Hi, the following code is part of a plugin called LoopLab and I am seeking help in resolving an issue. Right now the tool can't select multiple loops and was wondering if anyone has an idea on how to solve this issue. Thanks in advance!
model = Sketchup.active_model sel = model.selection edges = sel.grep(Sketchup;;Edge) # use = edges.last rerun = edges.last # run = true stp1 = false stp2 = false # skip = true # model.start_operation('LoopLab') # begin # edge = use faces = edge.faces v1 = edge.start v2 = edge.end v1_edges = v1.edges v2_edges = v2.edges # break if v1_edges.length > 4 || v2_edges.length > 4 # v1_edges.to_a.each { |ne| if not ne.used_by? faces[0] and not ne.used_by? faces[1] and not sel.include?(ne) use = ne sel.add ne stp1 = false break else stp1 = true end } # if skip == true skip = false next end # v2_edges.to_a.each { |ne| if not ne.used_by? faces[0] and not ne.used_by? faces[1] and not sel.include?(ne) use = ne sel.add ne stp2 = false break else stp2 = true end } # if stp1 and stp2 run = false end # end while run # # # run = true stp1 = false stp2 = false skip = true # begin # edge = rerun faces = edge.faces v1 = edge.start v2 = edge.end v1_edges = v1.edges v2_edges = v2.edges # break if v1_edges.length > 4 || v2_edges.length > 4 # v1_edges.to_a.each { |ne| if not ne.used_by? faces[0] and not ne.used_by? faces[1] and not sel.include?(ne) rerun = ne sel.add ne stp1 = false break else stp1 = true end } # if skip == true skip = false next end # v2_edges.to_a.each { |ne| if not ne.used_by? faces[0] and not ne.used_by? faces[1] and not sel.include?(ne) rerun = ne sel.add ne stp2 = false break else stp2 = true end } # if stp1 and stp2 run = false end # end while run # model.commit_operation # Sketchup.send_action('selectSelectionTool;')
-
Usually you hold the keyboard CTRL key to add items to the selection set.
-
You can collect all the separate loop-segments from the selection and then treat them separately.
If you made the assumption that the user only selected one edge in each of the loops he/she wants selected then it's easier - as you just need to iterate each edge in selection and build a loop for each one.
But it could be that the user selected multiple segments of a loop, in which you would have to detect this as well. Or, thinking of it, you could just ignore the fact that some are connected, just build the loop anyway and make sure you don't process an edge that's already in a generated loop.
Advertisement