检查文档

使用 sketchtool list 获取有关文档结构的信息。JSON 编码输出提供了层级结构和详细信息,包括每个层的名称、尺寸和位置。

注意:有关更多详细信息,您可以直接访问原始文档 JSON 编码数据。有关更多信息,请参阅文件格式文档

图层

列出文档的所有图层。

sketchtool list layers /path/to/document.sketch

输出

{
  "pages": [
    {
      "id": "9C1FA15B-CBEB-4448-ABFF-628D7FE1A537",
      "name": "Page 1",
      "bounds": "0.000000,0.000000,100.000000,100.000000",
      "layers": [
        {
          "layers": [],
          "trimmed": {
            "y": 0,
            "x": 0,
            "width": 100,
            "height": 100
          },
          "id": "3E0A01F1-482E-4A32-AD5B-EDF0B98575EA",
          "rect": {
            "y": 0,
            "x": 0,
            "width": 100,
            "height": 100
          },
          "relative": {
            "y": 0,
            "x": 0,
            "width": 100,
            "height": 100
          },
          "influence": {
            "y": 0,
            "x": 0,
            "width": 100,
            "height": 100
          },
          "name": "Rectangle"
        }
      ]
    }
  ]
}

画板

要仅列出画板,请运行以下命令

sketchtool list artboards /path/to/document.sketch

输出

{
  "pages": [
    {
      "id": "540D2F01-CE28-4E3B-A7A3-EAE9DA2A4EC8",
      "name": "Page 1",
      "bounds": "0,0,375.000000,812.000000",
      "artboards": [
        {
          "id": "1B7FCC8E-5030-43A5-94BE-28A9C7ABFF72",
          "name": "Artboard",
          "rect": {
            "y": 0,
            "x": 0,
            "width": 375,
            "height": 812
          },
          "trimmed": {
            "y": 0,
            "x": 0,
            "width": 375,
            "height": 812
          }
        }
      ]
    }
  ]
}

切片

要列出所有是切片或被标记为可导出的图层,请运行

 sketchtool list slices /path/to/document.sketch

输出

{
  "pages": [
    {
      "id": "9C1FA15B-CBEB-4448-ABFF-628D7FE1A537",
      "name": "Page 1",
      "bounds": "-25.000000,-25.000000,150.000000,150.000000",
      "slices": [
        {
          "rect": {
            "y": -25,
            "x": -25,
            "width": 150,
            "height": 150
          },
          "id": "94D3C09B-835E-46F1-8035-0B6A4CD9601B",
          "influence": {
            "y": -25,
            "x": -25,
            "width": 150,
            "height": 150
          },
          "name": "Slice",
          "trimmed": {
            "y": -25,
            "x": -25,
            "width": 150,
            "height": 150
          },
          "relative": {
            "y": -25,
            "x": -25,
            "width": 150,
            "height": 150
          }
        },
        {
          "rect": {
            "y": 0,
            "x": 0,
            "width": 100,
            "height": 100
          },
          "id": "3E0A01F1-482E-4A32-AD5B-EDF0B98575EA",
          "influence": {
            "y": 0,
            "x": 0,
            "width": 100,
            "height": 100
          },
          "name": "Rectangle",
          "trimmed": {
            "y": 0,
            "x": 0,
            "width": 100,
            "height": 100
          },
          "relative": {
            "y": 0,
            "x": 0,
            "width": 100,
            "height": 100
          }
        }
      ]
    }
  ]
}

页面

运行以下命令仅检索页面信息

 sketchtool list pages /path/to/document.sketch

输出

{
  "pages": [
    {
      "name": "Page 1",
      "id": "9C1FA15B-CBEB-4448-ABFF-628D7FE1A537",
      "bounds": "-25.000000,-25.000000,150.000000,150.000000"
    }
  ]
}