Gather all Section Views in the Project and their names.
Extract which Section View the Marker relates to.
Find the Section View ViewDirection and reverse this away from the viewer.
Compare the new ViewDirection angle to a temporary Plane (XZ Axis).
Process for unit conversion from internal units to degrees.
Apply some logic for converting the negative vectors to the angle numbering scheme you proposed in your image.
Happy Days
import clr
clr.AddReference('RevitAPI')
import Autodesk
from Autodesk.Revit.DB import *
clr.AddReference('RevitServices')
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
doc = DocumentManager.Instance.CurrentDBDocument
uiapp = DocumentManager.Instance.CurrentUIApplication
app = uiapp.Application
uidoc = uiapp.ActiveUIDocument
import math
#input
sectionMarkers = UnwrapElement(IN[0])
# Get all section views
allSectionViews = FilteredElementCollector(doc).OfClass(ViewSection).ToElements()
# Get all section view names
allSectionViewNames = []
for a in allSectionViews:
allSectionViewNames.append(a.Name)
result = []
for s in sectionMarkers:
# Get the View Name of the marker
sn = s.Name
snIndex = allSectionViewNames.index(sn)
sectionView = allSectionViews[snIndex]
# Get the right direction of the section view
sectionRDir = sectionView.ViewDirection.Negate()
# Compare the vector to an XZ plane
angle = sectionRDir.AngleOnPlaneTo(XYZ(0,1,0),XYZ(0,0,1))
degAngle = round(math.degrees(angle))-90
# Allow for rotation angle sorting
if degAngle < 0:
finalAngle = 360 + degAngle
else:
finalAngle = degAngle
result.append(finalAngle)
OUT = result