Block and Layer Visibility not exporting to DXF/DWG

Hey I'm not sure how many other people have been frustrated with Solidworks just disregarding your layer and block visibility selections but I found a solution.  For reference this addresses SPR 519084.

Wrote some code in C# that will edit the exported DXF file to freeze the desired layer when opened in AutoCad.  if you are exporting to DWG switch to DXF the below code will only work on a DXF.  Also if you are setting a block to hidden and having it show up after export then set the block to a layer and use this script to freeze the layer.

class Program
    {
        string layer { get; set; }
        static void Main(string[] args)
        {
            Program program = new Program();
            program.FreezeLayer(@"PUT YOUR FILE PATH HERE", "PUT YOUR LAYER NAME HERE");

        }

        void FreezeLayer(string filePath, string layer)
        {
            string[] dxf = System.IO.File.ReadAllLines(filePath);
           
            Program program = new Program();
            program.layer = layer;
            int location = Array.FindIndex(dxf, program.isLayer);
            location = location + 2;
            string layerState = dxf[location];
            layerState = "     1";
            dxf[location] = layerState;
            System.IO.File.WriteAllLines(filePath, dxf);
        }

        bool isLayer(String s)
        {
            if (s.Contains(layer))
            {
                return true;
            }
            else
            {
                return false;
            }
        }
       
    }

I hope this helps anybody that also has this issue.

SolidworksApi/macros