Seeing your pictures, I felt a bit more confused: it seems just as simple as creating a non-rectangle viewport, but why you made it sound so differently. Let me try to say what I saw from the pictures what you want to do:
1. in the first picture, it is a layout (paperspace) with a regular viewport, set to "PS" state. That is, through the viewport a polygon in the modelspace can be seen, but not touchable (until the viewport is turned to "MS" state). Here the entity seen in modelspace, be it a polyline or anything else, has nothing to do with what you are to do with viewport.
2. In picture 2, you draw a closed polyline on the layout, which is to be used to clip the only viewport on the layout.
3. in picture 3, you probably issued command VPCLICP, in the execution of the command, you pick the viewport first, then you picked the closed polyline you just drew. when the command is done, the viewport is gone (hidden, not erase, not changed), the polyline is used to show as non-rectangle viewport. and finally, the viewport is in "MS" state (thus, you can touch the entity inModelSpace through the viewport.
See the video below for the process.
So, the code I posted previously is perfectly apply to this case, and it is basically the same as the built-in command "VPCLIP. Thus, I am more confused as to what you really want.
Seeing you said "I am trying to get that details as well, the one which was erased and only clipped version remains.", I'd like remind you: the viewport is NOT ERASED. It is hidden. After clipping, if you select the non-rectangle viewport, in the properties window, you could see actually 2 entities are selected: a viewport and a polyline. that is because the polyline is now associated to the viewport as clipping border.
Sorry, I had hard time to understand you, probably not able to offer any more idea/help.