Anchored objects as in “Insert anchored object” and pasting a graphic line in there? (Which I couldn't make ID do, for some reason.)
Or do you mean the graphic lines are pasted in-line?
The problem with the first approach is the lines are inside another object (the anchored object), so you'd have to dig “one level” deeper. I didn't investigate that any further.
The other approach is no problem at all. A search for “^a” (Anchored Object, yessir) will return an array of all lines — and probably other inline stuff as well, but that's no problem. Each found item will have a property “graphicLines”, and if its length equals “1”, you have found an object consisting of one line. You could even check a bit further to assure the y coordinates of its start and end point are equal — if not, it's a slanted line instead ;-)
When you have a handle to the coordinates of the line, you can calculate the length of the line. It'll be in your local measurement units but that's not a problem. Remove the line, get the cursor position and add the length to it; then insert underscores until you have reached this target position (or about — it'll not be exact!).
You can also add underscores with an alternative method: clear all tabs between the start and end point, set a right aligned tab stop at the end and set the underscore as its dot leader. Then insert 1 tab. It'll also not be exact — ID rounds the number of underscores down, in whole underscore widths.
A final (and exact!) method is to add the tab stop and tab as above but not use a leader — underline the tab, and you're done.