Sorry I couldn't reply sooner. I was sick all of last week.
I'm amazed to see that Tim tossed off a complete new version of the program in one afternoon. I had been working on my failed version of it for a month. Thanks very much, Tim. When I get caught up and get some free time I'll study it and try to figure out how it works.
What about lines that are collinear and overlap. Are you going to consolidate them as well?
For my purposes there shouldn't be any overlapping or duplicate lines. If there were duplicate lines, it would be good to delete them, but I wouldn't want to delete any partially overlapping lines if any of those turn up.
I wanted this routine for cleaning up Sketchup-exported files. I like to model everything in 3D in Sketchup, and then export 2D views as DWG files (example attached). But in Sketchup's DWG export files, all lines are broken wherever they touch any other line. So it's hard to do any editing in the 2D file. They usually need some editing, especially if there were any curves in the Sketchup model.
Unfortunately, even the new version doesn't really work on those Sketchup-exported 2D DWG files. If I select a few lines at a time, it consolidates them; but if I select a large number of lines, it goes into a loop and I have to Esc from it.