Double nested Layer can not set to visible

Hello,
i have a psd with a visible SmartObject, containing a visible SmartObject. In the nested SmartObject is a layer, which I want to set .IsVisible = true;

I can do it, there is no exception, but the result is without the visible set layer.

Do you have any idea why this is not working?

Thanks
Carsten

@carsten.heinrich

Please check the following code. If it doesn’t work in your example, please provide the source code and the input file to help us find the reason.

            using (PsdImage psdImage = (PsdImage)Aspose.PSD.Image.Load(@"InnerSmart.psd"))
            {
                for (int i = 0; i < psdImage.Layers.Length; i++)
                {
                    var layer = psdImage.Layers[i] as SmartObjectLayer;
                    if (layer != null)
                    {
                        var innerImage = (PsdImage)layer.LoadContents(new PsdLoadOptions() { LoadEffectsResource = true });
                        for (int j = 0; j < innerImage.Layers.Length; j++)
                        {
                            innerImage.Layers[j].IsVisible = true;
                        }

                        layer.ReplaceContents(innerImage);
                        layer.UpdateModifiedContent();
                    }
                }

                psdImage.Save(@"InnerSmartOut.psd");
            }

Thank you!

The solution was (for me) to call ReplaceContents for each nested Layer.

1 Like