Skip to content

layerComps

LayerComps

Bases: Photoshop

The layer comps collection in this document.

Source code in photoshop/api/_layerComps.py
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
class LayerComps(Photoshop):
    """The layer comps collection in this document."""

    def __init__(self, parent):
        super().__init__(parent=parent)
        self._flag_as_method(
            "add",
            "removeAll",
        )

    def __len__(self):
        return self.length

    @property
    def length(self):
        return len(self._layers)

    @property
    def _layers(self):
        return list(self.app)

    @property
    def parent(self):
        return self.app.parent

    @property
    def typename(self):
        return self.app.typename

    def add(
        self,
        name,
        comment="No Comment.",
        appearance=True,
        position=True,
        visibility=True,
        childLayerCompStat=False,
    ):
        return LayerComp(self.app.add(name, comment, appearance, position, visibility, childLayerCompStat))

    def getByName(self, name):
        for layer in self._layers:
            if layer.name == name:
                return LayerComp(layer)
        raise PhotoshopPythonAPIError(f'Could not find a layer named "{name}"')

    def removeAll(self):
        self.app.removeAll()

    def __iter__(self):
        for layer in self._layers:
            yield LayerComp(layer)

Last update: 2024-11-17
Created: 2024-11-17