This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| selection.sketchObject.resizeToFitContentsIfNeededNoCache() //重置 symbol 尺寸 | |
| layer.select_byExpandingSelection(true,false) // 设置图层为选中状态 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var selectedLayers = context.selection; | |
| for (var i = 0, n = selectedLayers.count(); i < n; i++) { | |
| var layer = selectedLayers[i]; | |
| console.log(layer.frame().x()); | |
| console.log(layer.frame().y()); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| let sketch = require('sketch') | |
| let doc = sketch.getSelectedDocument() | |
| let selection = doc.selectedLayers.layers[0] //basic rect layer | |
| let randomRadius = Math.round((Math.random()*100)) | |
| console.log("randomRadius: " + randomRadius) | |
| selection.points.forEach(point => point.cornerRadius = randomRadius) | |
| selection.sketchObject.setFixedRadius(randomRadius) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| A list of sketch scripts |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const tokenArray = [ | |
| { name: 'color-background-default', value: '#f5f7fa'}, | |
| { name: 'color-background-white', value: '#fff'}, | |
| { name: 'color-background-dark', value: '#202d40'}, | |
| { name: 'color-background-tooltip', value: '#202d40'}, | |
| { name: 'color-background-message-warning', value: '#fffbe5'}, | |
| { name: 'color-background-message-success', value: '#f2ffe0'}, | |
| { name: 'color-background-message-error', value: '#fff0f0'}, | |
| { name: 'color-background-message-info', value: '#e6f7ff'}, | |
| { name: 'color-background-list-row-hover', value: '#f5f7fa'}, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const sketch = require("sketch") | |
| const document = sketch.getSelectedDocument() | |
| const selection = document.selectedLayers.layers | |
| const Group = sketch.Group | |
| const Style = sketch.Style | |
| const Rectangle = sketch.Rectangle | |
| const Artboard = sketch.Artboard | |
| const ShapePath = sketch.ShapePath | |
| const Text = sketch.Text | |
| const SymbolInstance = sketch.SymbolInstance |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var sketch = require('sketch') | |
| var getSelectedDocument = require('sketch/dom').getSelectedDocument; | |
| const document = getSelectedDocument().pages[0].layers; | |
| console.info(JSON.stringify(document)); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var sketch = require('sketch') | |
| var Style = sketch.Style | |
| var Rectangle = sketch.Rectangle | |
| var ShapePath = sketch.ShapePath | |
| var doc = sketch.getSelectedDocument() | |
| var selection = doc.selectedLayers | |
| var myShape = new ShapePath({ | |
| name: 'my shape', | |
| frame: new Rectangle(20,20,100,200), |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| let sketch = require('sketch') | |
| let doc = sketch.getSelectedDocument() | |
| let selectedLayersObject = doc.selectedLayers | |
| let selectedLayersArray = selectedLayersObject.layers | |
| //console.log(selectedLayersArray[0]) | |
| selectedLayersArray.forEach(layer => { | |
| //console.log(layer.layers) | |
| layer.layers.forEach(lay => { | |
| console.log(lay.remove()) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var sketch = context.api() | |
| var document = sketch.selectedDocument; | |
| var selection = document.selectedLayers; | |
| var command = context.command; | |
| var selectedLayer = context.document.selectedLayers().firstLayer() | |
| console.log(selectedLayer) |