sketchucation logo sketchucation
    • Login
    🤑 SketchPlus 1.3 | 44 Tools for $15 until June 20th Buy Now

    LoopLab Help

    Scheduled Pinned Locked Moved Developers' Forum
    3 Posts 3 Posters 251 Views 3 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.
    • renderizaR Offline
      renderiza
      last edited by

      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;')
      

      [url=https://www.sketchupcode.com/:z3kqsidd]My Extensions ...[/url:z3kqsidd]

      1 Reply Last reply Reply Quote 0
      • Dan RathbunD Offline
        Dan Rathbun
        last edited by

        Usually you hold the keyboard CTRL key to add items to the selection set.

        I'm not here much anymore.

        1 Reply Last reply Reply Quote 0
        • tt_suT Offline
          tt_su
          last edited by

          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.

          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