• Login
sketchucation logo sketchucation
  • Login
πŸ€‘ SketchPlus 1.3 | 44 Tools for $15 until June 20th Buy Now

Plugin search help -- combining lines

Scheduled Pinned Locked Moved Newbie Forum
sketchup
29 Posts 7 Posters 1.1k Views 7 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.
  • A Offline
    agamemnus
    last edited by 1 Mar 2011, 21:35

    There was a plugin a few months ago that combined lines going in the same direction into one line. I forgot the name. Can anyone help me? ❓

    1 Reply Last reply Reply Quote 0
    • D Offline
      Dave R
      last edited by 1 Mar 2011, 22:07

      Weld?

      Etaoin Shrdlu

      %

      (THERE'S NO PLACE LIKE)

      G28 X0.0 Y0.0 Z0.0

      M30

      %

      1 Reply Last reply Reply Quote 0
      • R Offline
        Rich O Brien Moderator
        last edited by 1 Mar 2011, 22:14

        Conbobulator?

        Download the free D'oh Book for SketchUp πŸ“–

        1 Reply Last reply Reply Quote 0
        • M Offline
          mitcorb
          last edited by 1 Mar 2011, 22:18

          Whut?

          I take the slow, deliberate approach in my aimless wandering.

          1 Reply Last reply Reply Quote 0
          • R Offline
            Rich O Brien Moderator
            last edited by 1 Mar 2011, 22:24

            Bored πŸ˜’

            Download the free D'oh Book for SketchUp πŸ“–

            1 Reply Last reply Reply Quote 0
            • D Offline
              Dave R
              last edited by 1 Mar 2011, 22:29

              Darn! I was off searching for a new plugin. 😑 πŸ˜† 🀣

              Etaoin Shrdlu

              %

              (THERE'S NO PLACE LIKE)

              G28 X0.0 Y0.0 Z0.0

              M30

              %

              1 Reply Last reply Reply Quote 0
              • A Offline
                agamemnus
                last edited by 1 Mar 2011, 23:53

                I think it's "weld", but I just can't find the thread for it. I found one weld thread here: http://forums.sketchucation.com/viewtopic.php?t=8784 , but that welds lines that aren't combined, so I'm not sure that's it.

                1 Reply Last reply Reply Quote 0
                • R Offline
                  Rich O Brien Moderator
                  last edited by 1 Mar 2011, 23:54

                  Weld is hosted on Smustard.com

                  Download the free D'oh Book for SketchUp πŸ“–

                  1 Reply Last reply Reply Quote 0
                  • D Offline
                    Dave R
                    last edited by 2 Mar 2011, 00:00

                    Weld.rb

                    Etaoin Shrdlu

                    %

                    (THERE'S NO PLACE LIKE)

                    G28 X0.0 Y0.0 Z0.0

                    M30

                    %

                    1 Reply Last reply Reply Quote 0
                    • T Offline
                      TIG Moderator
                      last edited by 2 Mar 2011, 00:02

                      Weld makes the selected edges into a bound set of edges in a 'curve' - they are still there with ends.

                      Thomthom's EdgeTools can heal colinear lines.........

                      TIG

                      1 Reply Last reply Reply Quote 0
                      • A Offline
                        agamemnus
                        last edited by 2 Mar 2011, 00:31

                        Hmm, that works, but I have to specifically select those edges (can't just select basic polys/edges in whole group, either) and then use "colinear from start to end"... (it also repositions the texture in some fashion.) Won't help with split edges that I didn't know existed.

                        1 Reply Last reply Reply Quote 0
                        • T Offline
                          TIG Moderator
                          last edited by 2 Mar 2011, 00:36

                          If this relates to the PM about a 'rectangle with 5 edges after a joined edge is deleted'... simply make sure nothing is selected, activate the Move Tool, hover over the rogue vertex location [use a Style showing EndPoints so its easier to spot them] then move the vertex [NOT the edge] so the short part is 'shrunk' to zero length - you might need Alt to get auto-fold to kick in in some cases... Now you have lost an unnecessary edge and vertex, and the rectangle has 4 sides as it ought. πŸ˜„

                          TIG

                          1 Reply Last reply Reply Quote 0
                          • B Offline
                            Builder Boy
                            last edited by 2 Mar 2011, 02:06

                            If the lines are all going the same direction, then you can use this:


                            repair_broken_lines.rb

                            All my plugins

                            1 Reply Last reply Reply Quote 0
                            • A Offline
                              agamemnus
                              last edited by 2 Mar 2011, 05:48

                              Thanks Builder Boy. That hit the spot. πŸ’š

                              1 Reply Last reply Reply Quote 0
                              • A Offline
                                agamemnus
                                last edited by 4 Mar 2011, 06:20

                                A problem with that script is that it does not seem to always dig inside groups/components correctly and misses some lines. πŸ˜•

                                Edit: tried this.... doesn't work. I have a feeling I am missing something.

                                Edit 2: Used "if (e.class != Sketchup::Face)" instead of
                                "if (e.class == Sketchup::Group)"... why does one work and not the other? (the == group one doesn't seem to hit?) Also... any better solutions here? This is the best I could cobble up..

                                
                                require 'sketchup.rb'
                                # (c) Carlo Roosen 2004
                                
                                def repair_broken_lines (eparent)
                                  total = 0
                                  trunk = Array.new
                                  ss = eparent.entities
                                  #search all edges in selection set
                                  for e in ss
                                    if (e.kind_of?(Sketchup;;Edge))
                                      p=e.parent
                                      #take both vertices 
                                      for v in e.vertices 
                                        #take all edges connected to v (including e)
                                        es=v.edges
                                        #when two edges are connected
                                        if (es.length==2)
                                          vec1 = es[0].line[1]
                                          vec2 = es[1].line[1]
                                          #and both are in the same direction
                                          if (vec1.parallel?(vec2))
                                            #then the two lines can be repaired
                                            #this is done by generating a new line from the vertex to a random point
                                            l = p.entities.add_line (v.position, Geom;;Point3d.new(3.45,6.78,9.12))
                                            #and put that line in a trunk
                                            trunk.push(l)
                                          end
                                        end
                                      end
                                	else
                                	 if (e.class != Sketchup;;Face)
                                	  total += repair_broken_lines (e) 
                                	 end
                                	end
                                  end
                                
                                  #erase all lines in trunk
                                  total += trunk.length
                                  for l in trunk
                                    l.erase!
                                  end
                                  return total
                                end
                                
                                def repair_broken_lines_recurse
                                
                                 total = 0;
                                 m = Sketchup.active_model;
                                 
                                 # Define everything as one undo operation.
                                 m.start_operation "Repair Broken Lines"
                                 total = repair_broken_lines (m)
                                 UI.messagebox ("#{total} lines repaired")
                                 m.commit_operation
                                end
                                
                                
                                selection=Sketchup.active_model.selection
                                if( not file_loaded?("repair_broken_lines.rb") )
                                    UI.add_context_menu_handler do |context_menu| 
                                        if selection.count>1
                                           context_menu.add_item("Repair Broken Lines") { repair_broken_lines_recurse }
                                        end
                                    end
                                end
                                
                                UI.menu("Plugins").add_item("Repair Broken Lines") { repair_broken_lines_recurse }
                                
                                file_loaded ("repair_broken_lines.rb")
                                
                                
                                1 Reply Last reply Reply Quote 0
                                • T Offline
                                  TIG Moderator
                                  last edited by 5 Mar 2011, 13:18

                                  Here's my working version...

                                  ### Original idea (c) Carlo Roosen 2004
                                  ### Modified (c) TIG 2011 
                                  ### Now also repairs edges inside groups/instances in selection...
                                  ###
                                  require 'sketchup.rb'
                                  ###
                                  class Repair_broken_lines
                                   def initialize(ents=nil)
                                    model=Sketchup.active_model
                                    lines_to_go=[]
                                    if not ents
                                      $total_repair_broken_lines=0
                                      ss=model.selection.to_a
                                      begin
                                        model.start_operation("Repair Broken Lines",true)
                                      rescue
                                        model.start_operation("Repair Broken Lines")
                                      end
                                    else
                                      ss=ents
                                    end#if
                                    #check all edges in selection set OR entities passed as argument
                                    ss.each{ |e|
                                      if e.kind_of?(Sketchup;;Edge) #take both vertices 
                                        e.vertices.each{ |v| #take all edges connected to v (including e)
                                          es=v.edges #when two edges are connected
                                          if es.length==2
                                            vec1=es[0].line[1]
                                            vec2=es[1].line[1] #and both are in the same direction
                                            if vec1.parallel?(vec2) #then the two lines can be repaired
                                              #make a new line from that vertex to a random point
                                              pt=Geom;;Point3d.new(1+rand, 1+rand, 1+rand)
                                              nline=e.parent.entities.add_line(v.position, pt)
                                              lines_to_go << nline if nline and nline.valid?
                                            end#if
                                          end#if
                                        }#end v
                                      elsif e.kind_of?(Sketchup;;Group)
                                        Repair_broken_lines.new(e.entities.to_a)
                                      elsif e.kind_of?(Sketchup;;ComponentInstance)
                                        Repair_broken_lines.new(e.definition.entities.to_a)
                                      end#if
                                    }#end e
                                    if not $total_repair_broken_lines
                                      $total_repair_broken_lines=lines_to_go.length
                                    else
                                      $total_repair_broken_lines=$total_repair_broken_lines + lines_to_go.length
                                    end#if
                                    lines_to_go.each{ |e| e.erase! if e.valid? }#erase all lines_to_go
                                    if not ents
                                      model.commit_operation 
                                      UI.messagebox("#{$total_repair_broken_lines} Lines Repaired.")
                                    end#if
                                   end#def initialize
                                  end#class
                                  ###
                                  if not file_loaded?(File.basename(__FILE__))
                                    if $submenu4 # TIG menus
                                      $submenu4.add_item("Repair Broken Lines [Selection]"){ Repair_broken_lines.new() }
                                    else
                                      UI.menu("Plugins").add_item("Repair Broken Lines [Selection]"){ Repair_broken_lines.new() }
                                    end
                                  end
                                  file_loaded(File.basename(__FILE__))
                                  ###
                                  
                                  

                                  TIG

                                  1 Reply Last reply Reply Quote 0
                                  • A Offline
                                    agamemnus
                                    last edited by 6 Mar 2011, 01:46

                                    Thanks. Looks like you made total_repair_broken_lines a global. That makes more sense than to create a useless stack as I did. I didn't want to create a stack either but I didn't want to create a global, and I am not 100% familiar with Ruby/am a bit forgetful. I did some searching now though and I see that @@ is class scope, so how about @@ instead of $?

                                    If the code stays here people won't be able to find it very easily. How about re-releasing this plugin, as well as that "default face" snippet you made earlier for me, in the plugins forum?

                                    Also: another problem I noticed is that it tries to repair lines that aren't repairable, like curve endings and single lines. (attached)

                                    
                                        ### Original idea (c) Carlo Roosen 2004
                                        ### Modified (c) TIG 2011
                                        ### Now also repairs edges inside groups/instances in selection...
                                        ###
                                        require 'sketchup.rb'
                                        ###
                                        class Repair_broken_lines
                                        def initialize(ents=nil)
                                          model=Sketchup.active_model
                                          lines_to_go=[]
                                          if not ents
                                            @@total_repair_broken_lines=0
                                            ss=model.selection.to_a
                                            begin
                                              model.start_operation("Repair Broken Lines",true)
                                            rescue
                                              model.start_operation("Repair Broken Lines")
                                            end
                                          else
                                            ss=ents
                                          end#if
                                          #check all edges in selection set OR entities passed as argument
                                          ss.each{ |e|
                                            if e.kind_of?(Sketchup;;Edge) #take both vertices
                                              e.vertices.each{ |v| #take all edges connected to v (including e)
                                                es=v.edges #when two edges are connected
                                                if es.length==2
                                                  vec1=es[0].line[1]
                                                  vec2=es[1].line[1] #and both are in the same direction
                                                  if vec1.parallel?(vec2) #then the two lines can be repaired
                                                    #make a new line from that vertex to a random point
                                                    pt=Geom;;Point3d.new(1+rand, 1+rand, 1+rand)
                                                    nline=e.parent.entities.add_line(v.position, pt)
                                                    lines_to_go << nline if nline and nline.valid?
                                                  end#if
                                                end#if
                                              }#end v
                                            elsif e.kind_of?(Sketchup;;Group)
                                              Repair_broken_lines.new(e.entities.to_a)
                                            elsif e.kind_of?(Sketchup;;ComponentInstance)
                                              Repair_broken_lines.new(e.definition.entities.to_a)
                                            end#if
                                          }#end e
                                          if not @@total_repair_broken_lines
                                            @@total_repair_broken_lines=lines_to_go.length
                                          else
                                            @@total_repair_broken_lines=@@total_repair_broken_lines + lines_to_go.length
                                          end#if
                                          lines_to_go.each{ |e| e.erase! if e.valid? }#erase all lines_to_go
                                          if not ents
                                            model.commit_operation
                                            UI.messagebox("#{@@total_repair_broken_lines} Lines Repaired.")
                                          end#if
                                        end#def initialize
                                        end#class
                                        ###
                                        if not file_loaded?(File.basename(__FILE__))
                                          if $submenu4 # TIG menus
                                            $submenu4.add_item("Repair Broken Lines [Selection]"){ Repair_broken_lines.new() }
                                          else
                                            UI.menu("Plugins").add_item("Repair Broken Lines [Selection]"){ Repair_broken_lines.new() }
                                          end
                                        end
                                        file_loaded(File.basename(__FILE__))
                                        ###
                                    
                                    

                                    circle.skp

                                    1 Reply Last reply Reply Quote 0
                                    • T Offline
                                      TIG Moderator
                                      last edited by 6 Mar 2011, 11:28

                                      You are right about setting the variable to 'class' using @@ rather than 'global' with $ - it's much safer - I was churning that out rather too quickly... πŸ˜’
                                      The 'trick' to force broken edges into one only works on plain edges.
                                      With an edge that's part of a curve it can't... for you next step why not see if you can find all edges that are co-linear [it already does that and if one is part of a curve then remember all of the curves edges in an array and then explode the curve, immediately remake the curve leaving out the one edge you want to heal. Then it will heal back into its co-linear mate... It just needs a test in the iterated loops... πŸ€“
                                      When 'we' get it 'perfect' then 'we' could issue a joint 3-way update... πŸ˜‰

                                      TIG

                                      1 Reply Last reply Reply Quote 0
                                      • R Offline
                                        Rich O Brien Moderator
                                        last edited by 6 Mar 2011, 11:32

                                        You mean 4-way

                                        Download the free D'oh Book for SketchUp πŸ“–

                                        1 Reply Last reply Reply Quote 0
                                        • T Offline
                                          TIG Moderator
                                          last edited by 6 Mar 2011, 11:34

                                          @unknownuser said:

                                          You mean 4-way

                                          Like "Additional semi-humorous material supplied by Rich O'Brien." πŸ˜‰

                                          TIG

                                          1 Reply Last reply Reply Quote 0
                                          • 1
                                          • 2
                                          • 1 / 2
                                          1 / 2
                                          • First post
                                            1/29
                                            Last post
                                          Buy SketchPlus
                                          Buy SUbD
                                          Buy WrapR
                                          Buy eBook
                                          Buy Modelur
                                          Buy Vertex Tools
                                          Buy SketchCuisine
                                          Buy FormFonts

                                          Advertisement