Determining Casts and Receives shadows

I found an ugly trick, to get a selection of all Recieving and Casting Meshes:
(My level of suffering was high enough, to use this)

    Dim myDoc As RhinoDoc = RhinoDoc.ActiveDoc
    Dim myIdsCast As New Rhino.Collections.RhinoList(Of Guid)
    Dim myIdsRec As New Rhino.Collections.RhinoList(Of Guid)
    Dim settings As New Rhino.DocObjects.ObjectEnumeratorSettings()
    settings.ObjectTypeFilter = Rhino.DocObjects.ObjectType.Mesh

    For Each obj As Rhino.DocObjects.RhinoObject In myDoc.Objects.GetObjectList(settings)

        Rhino.RhinoApp.ClearCommandHistoryWindow()
        Rhino.RhinoApp.RunScript("SelID " & obj.Id.ToString, True)
        Rhino.RhinoApp.RunScript("-Properties o ReceivesShadows _Enter CastsShadows _Enter _Enter _Enter", True)
        Rhino.RhinoApp.RunScript("SelNone", True)

        Dim myHistory As String = Rhino.RhinoApp.CommandHistoryWindowText

        If myHistory.Contains("Receives shadows <Yes>") Then
            myIdsRec.Add(obj.Id)
        End If

        If myHistory.Contains("Casts shadows <Yes>") Then
            myIdsCast.Add(obj.Id)
        End If
    Next