CadLayerTable type variable - How to identify is the layer is visible or not?

How do I identify if a layer is hidden/invisible or not? I have written a small piece of code below using the Aspose.CAD nuget package in C# .NET - It iterates through the layers of the CAD Image and provides some basic info (the LogIt function just writes the string output - kinda similar to console output).
It’s useful, but I would like to be able to do two things:
Tell if a layer is visible/hidden
Hide/Un-Hide a layer
I am not in control of the source .DWG file and I need to perform some actions based on whether the layer is hidden or not - Is there any way to achieve this?

            using (Aspose.CAD.Image image = Aspose.CAD.Image.Load(selectFile.FileName))
            {
                Aspose.CAD.FileFormats.Cad.CadImage cadImage = (Aspose.CAD.FileFormats.Cad.CadImage)image;
                Aspose.CAD.FileFormats.Cad.CadLayersList layers = cadImage.Layers;

                foreach(CadLayerTable Layer in layers)
                {

                    LogIt("Layer Name: " + Layer.Name);
                    LogIt("Color ID: " + Layer.ColorId.ToString());
                    LogIt("Plot Flag Has Value: " + Layer.PlotFlag.HasValue.ToString());
                    LogIt("Plot Flag Value: " + Layer.PlotFlag.ToString());
                    LogIt("\n");
                }

            }

@Wahida_Massan,
Hello.
Please try to analyze Layer.ColorId: the layer is off when this value is negative.

1 Like

Thank you very much - I can confirm that this is the case. It’s weird that there is a function specifically to tell if a layer is hidden or not, but this works well for my purposes.

1 Like

@Wahida_Massan,
thank you, we were happy to help :slight_smile: