Hi,
This line ask user to select a viewport on screen. If you already have the viewport (iterate through your viewport selection set), you got to skip this step, and put your viewport directly in
(if (and (= (getvar "cmdactive") 0)
(/= (setq ss (ssget ":E:S" '((0 . "VIEWPORT")))) nil)
)
Replace
;replace this: (setq ent (ssname ss 0))
;with this:
(setq ent yourviewporthere)
Also the vpsel function pass the result to the grip selection, then nullify the result at the end (setq ss nil ss1 nil)
While you want to get the result, so, you got to comment out that line, and take the ss1 result out of the function, merge it to your rrr selection