コード例 #1
0
ファイル: Action.cs プロジェクト: solarbluseth/thecodingfrog
        /// <summary>
        /// Exports the smart objects.
        /// </summary>
        /// <param name="__docRef">Document refrence</param>
        /// <param name="_layers">Layers</param>
        /// <returns></returns>
        private bool exportSmartObjects(Photoshop.Document __docRef, object _layers)
        {
            Photoshop.Layers __layers;
            Photoshop.ArtLayer __alayer = null;
            Photoshop.LayerSet __slayer;
            bool __isArtLayer = false;
            object __layer;
            int __j;
            string __soType;

            __layers = (Photoshop.Layers)_layers;

            for (__j = 1; __j <= __layers.Count; __j++)
            {
                __layer = __layers[__j];

                try
                {
                    __alayer = (Photoshop.ArtLayer)__layer;
                    __isArtLayer = true;
                }
                catch
                {
                    __isArtLayer = false;
                }

                if (__isArtLayer) // Everything as Layer goes here
                {
                    __appRef.ActiveDocument.ActiveLayer = __layer;

                    if (__alayer.Kind == Photoshop.PsLayerKind.psSmartObjectLayer)
                    {

                        int __idplacedLayerExportContents;
                        __idplacedLayerExportContents = __appRef.StringIDToTypeID("placedLayerExportContents");

                        Photoshop.ActionDescriptor __desc4;
                        __desc4 = new Photoshop.ActionDescriptor();

                        int __idnull;
                        __idnull = __appRef.CharIDToTypeID("null");

                        if (!Directory.Exists(__docRef.Path + "+ SmartObjects\\"))
                        {
                            Directory.CreateDirectory(__docRef.Path + "+ SmartObjects\\");
                        }

                        __soType = getSmartObjectType(__appRef);
                        if (__soType != "")
                        {
                            __desc4.PutPath(__idnull, __docRef.Path + "+ SmartObjects\\" + wipeName(__alayer.Name) + __soType);
                            __appRef.ExecuteAction(__idplacedLayerExportContents, __desc4, Photoshop.PsDialogModes.psDisplayNoDialogs);
                        }
                    }
                }
                else // Everything as LayerSet goes here
                {
                    __slayer = (Photoshop.LayerSet)__layer;
                    __appRef.ActiveDocument.ActiveLayer = __layer;

                    if (__slayer.LayerType == Photoshop.PsLayerType.psLayerSet)
                    {
                        bool __test = exportSmartObjects(__docRef, __slayer.Layers);
                    }
                }
            }
            return true;
        }