You may want to clarify this:
...if the Object ar in any Viewport
When you say "Viewport", I assume it is a Viewport opened on given layout (PaperSpace).
Does "Objects are in any Viewport" mean objects in ModelSpace that can be seen in the Viewport on layout? If so, these objects are in ModelSpace obviously.
Or Do you mean objects actually in the PaperSpace of the layout but happen to sit in the area where a Viewport covers. In this case, why even mention Viewport? It has nothing to do with finding these objects' layout name.
But since you say "select object in paperspace and get Layout name", you can find any entity's layout name (including "Model" for ModelSpace, like this extension method (not tested):
Public static string GetEntityLayoutName(this ObjectId entId)
{
var layoutName="";
using (var tran = entId.Database.TransactionManager.StartTransaction())
{
var ent = (Entity) tran.GetObject(entId, OpenMode.ForRead);
var owner = (BlockTableRecord)tran.GetObject(ent.OwnerId, OpenMode.ForRead);
If (owner.IsLayout)
{
var layout = (Layout)tran.GetObject(owner.LayoutId, OpenMode.ForRead);
layoutName = layout.LayoutName;
}
tran.Commit();
}
return layoutName;
}