Like ronjonp you can use a filter "main,sub,local" for the layers then get each pline and check the layer so where I ask is "main" etc just use a check what layer instead.
Please confirm your layer names, then all can be done in one go. Can do select an object get its layer name but use "Main" as line style.