@Andrey-SPGR,
If your question does not receive an answer, it usually means it does not make sense for anyone around.the forum.
Remember, not everyone is an MEP specialist, or knows what a tray/frame is.
Try to reformulate, illustrate with screen capture or code what you are trying to achieve.
Agree with Jean-Marc that the question is a little vague. If “selected by frame” means “elements in the view”, then you can simple add the view id to your filtered element collector, like this:
if you want to collect only the selected cable tray elements, you can do it this way (non cable tray elements will be filtered out if they are selected as well):
uidoc = revit.uidoc
selection = uidoc.Selection.GetElementIds()
categoryid = DB.ElementId(DB.BuiltInCategory.OST_CableTray)
cable_tray_collector = [doc.GetElement(id) for id in selection if doc.GetElement(id).Category.Id.Equals(categoryid)]