@kgrupenhof :
I tested your Sample_Linework.dwg. I set the current entity color, CECOLOR, to magenta so I could easily see the changes.
Though it did a lot, MendLines did not mend everything.
I undid and increased the angular fuzz factor in the program and loaded and ran it again. It did a better job of mending, which means that some apparently straight tangents contain segments that are not exactly collinear. Also bear in mind that if the program does not find more than one collinear lines, then it will leave the singular one alone.
I am concerned that increasing the fuzz factor too much will do mending that shouldn't be done and modify your drawing improperly.
Perhaps it would be better to increase the fuzz factor but join the segments into a lightweight polyline by filling in the gaps. That could be a lot more code and processing time, but each original segment will be left in place. I think a lightweight polyline with many vertices is a lot less data than as many separate lines. Then again, since I think you are trying only to clean up utilities, I doubt that shifting a vertex by a tiny amount means anything.* As to connecting adjacent lines at different angles, I don't think I will spend the time to do that, but you could use the PJOIN I posted, which allows you to decide what should be joined to what.
I'll think about it. In the meanwhile, I think the MendLines.lsp I posted at least reduces your labor immensely.
I think I'll change the reporting at the end to indicate the net reduction in line segments and the percentage of the total. Do you want to know the number of text objects deleted?
* Around my region, markouts of existing utilities are approximate at best, and proposed utilities are drawn by eye. There is no accuracy. The plans always have notes requiring the contractor to verify the location of utilities, even by hand digging.