GithubHelp home page GithubHelp logo

bomberstudios / sketch-commands Goto Github PK

View Code? Open in Web Editor NEW
823.0 43.0 50.0 519 KB

A collection of script commands for Sketch.app

JavaScript 100.00%
sketch-plugin sketch sketch-app sketchapp sketch-commands

sketch-commands's Introduction

Sketch Commands

Sketch Commands is a port of some of my Orange Commands for Fireworks for Sketch.app.

Installation

Documentation for All Commands

Align

  • Space Horizontal: Distributes the selected elements horizontally, with the same distance beetween them.
  • Space Vertical: Distributes the selected elements vertically, with the same distance beetween them.

Duplicate

  • Duplicate Artboard Below: Duplicates the selected Artboard to the bottom of the current one.
  • Duplicate Artboard Right: Duplicates the selected Artboard to the right of the current one.

Effects

  • Repeat Horizontal: Repeats the selected layer horizontally, with a custom spacing between layers.
  • Repeat Vertical: Repeats the selected layer vertically, with a custom spacing between layers.

Export

  • All Artboards as PNG: Exports all the Artboards in the document as PNG files, in a folder at the file's location.
  • All Artboards as PNG in…: Exports all the Artboards in the document as PNG files, in a folder of your choice.
  • All Artboards as SVG: Exports all the Artboards in the document as SVG files, in a folder at the file's location.
  • All Artboards as PDF: Exports all the Artboards in the document as independent PDF files (one PDF file per Artboard), in a folder at the file's location.
  • All Slices as PNG: Exports all the Slices in the document as PNG files, in a folder at the file's location.
  • All Slices as PNG in ZIP: Exports all the Slices in the document as PNG files, archived in a ZIP file.
  • All Slices as PNG in…: Exports all the Slices in the document as PNG files, in a folder of your choice.
  • All Slices as SVG: Exports all the Slices in the document as SVG files, in a folder at the file's location.
  • All Slices as PDF: Exports all the Slices in the document as independent PDF files (one PDF file per Slice), in a folder at the file's location.
  • Save and Export Slices: Saves the file, exporting all the Slices in PNG format, in a folder at the file's location.
  • Selection to Desktop as PNG: Exports the selected layers as a PNG file on the Desktop.
  • Selection to Desktop as SVG: Exports the selected layers as a SVG file on the Desktop.
  • Selection to Desktop as PDF: Exports the selected layers as a PDF file on the Desktop.
  • Whole Page to Desktop as PNG: Exports the current page as a PNG file on the Desktop.
  • Whole Page to Desktop as PDF: Exports the current page as a PDF file on the Desktop.

Guides

  • Add Guides Manually to Artboard: Adds a pair of horizontal & vertical guides to the current Artboard, at the specified coordinates.
  • Around Selection: Add four guides that frame each of the selected layers.
  • Clear All Guides in Current Artboard: Removes all the guides in the current Artboard.
  • Clear All Guides in Current Page: Removes all the guides in the current Page.
  • Clear All Guides: Removes all the guides in the current document.
  • Clear Horizontal Guides in Current Page: Removes all the horizontal guides in the current Page.
  • Clear Vertical Guides in Current Page: Removes all the vertical guides in the current Page.
  • Repeat Guides Horizontally on Artboard: Creates a repeating pattern of horizontal guides by specifying the starting position of the pattern, distance between guides, and number of guides.
  • Repeat Guides Vertically on Artboard: Creates a repeating pattern of vertical guides by specifying the starting position of the pattern, distance between guides, and number of guides.

Numberize

A collection of commands to add / remove numbers to the name of Pages and Artboards.

  • Artboards Add: Adds a number in front of the Artboard name, using their stacking order.
  • Artboards Remove: Removes the number added by the previous command.
  • Pages Add: Adds a number in front of the name of all pages.
  • Pages Remove: Removes the number added by the previous command.

Pages

  • Duplicate Current Page: Duplicates the current page in the document.
  • Remove Current Page: Removes the current page in the document.
  • Set Name…: Sets the name of the current page.

Position

  • Move Up 100px: Moves the selected layers 100 pixels up.
  • Move Down 100px: Moves the selected layers 100 pixels down.
  • Move Left 100px: Moves the selected layers 100 pixels left.
  • Move Right 100px: Moves the selected layers 100 pixels right.
  • Set Position…: Sets the position of the selected layers to a custom value.
  • Swap Positions: Swaps the positions of two selected layers.

Properties

  • Make Pill: Makes the selected Rectangle layer a pill button by rounding its corners to the maximum possible value.
  • Rotation…: Sets the rotation of the selected layers to a custom value.
  • Set Radius…: Sets the corner radius of the selected layers to a custom value.

Select

  • All Layers in Current Artboard: Selects all the layers in the current Artboard.
  • All Text Layers in Page: Selects all the text layers in the current Page.
  • Current Artboard: Selects the current Artboard.

Size

  • Equalize Height Down: Makes all selected objects the same height, using the shortest one as the reference.
  • Equalize Height Up: Makes all selected objects the same height, using the tallest one as the reference.
  • Equalize Width Down: Makes all selected objects the same width, using the narrowest one as the reference.
  • Equalize Width Up: Makes all selected objects the same width, using the widest one as the reference.
  • Height -100px: Decreases the height of the selected layers by 100px.
  • Height +100px: Increases the height of the selected layers by 100px.
  • Height…: Sets the height of the selected layers to a custom value.
  • Scale to 16:9: Scales the selected layers so that they have a 16:9 aspect ratio.
  • Scale to 4:3: Scales the selected layers so that they have a 4:3 aspect ratio.
  • Set Size…: Sets the size of the selected layers to a custom value.
  • Width -100px: Decreases the width of the selected layers by 100px.
  • Width +100px: Increases the width of the selected layers by 100px.
  • Width…: Sets the width of the selected layers to a custom value.

Text

See this article for more details on Sentence vs Title case.

  • Case Sentence case: Sets the selected text layers to Sentence case.
  • Case Title Case: Sets the selected text layers to Title Case.

sketch-commands's People

Contributors

bomberstudios avatar bre7 avatar hugocornejo avatar ianfixes avatar joethephish avatar mamuso avatar ricburton avatar tarngerine avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

sketch-commands's Issues

Select all art boards

Create a command that will select all art boards in a page for the purpose of re-alining with the grid tool.

  • Would be nice if the function could collapse all art boards as well.

Unlock all locked layers

Sometimes, locked layers are in nested groups, which are so hard to find.

Can I request this feature here?

Clear Guides on Page – Not Working

All the Clear Guides on Page (All, Vertical and Horizontal) don't seem to work for me. I tried a few different setups (multiple art boards, selected, un-selected, etc) but it never seems to work.

Export Artboards to @2x +

Hi,

Love this plugin but I can't seem to export to @2x PNG any tricks on how I can edit this plugin to do this?

Thanks,
Mario

Request: Export - All Artboards as PNG's

Would it be possible to enhance this command by creating a folder (on export) for each page in the Sketch document?

Right now if you have the same name within different pages the exports get overwritten by each other. Hope that makes sense.

Go to Next/Previous Page, open Pages drawer

Hi, is it possible to script shortcuts for going to the next page / previous page and opening the drawer of pages?

I could have sworn earlier versions of Sketch had shortcuts for these but I haven't been able to find anything about that. Navigating between pages is my main point of frustration with Sketch right now.

export doesn't see all artboards

All artboards are set correctly but when i click 'export' it does see 21 out of 29 artboards to select.
I'm not sure if i'm doing something wrong at this point. Is there a limit to artboards to be exported?

Sketch crashes when using the export Script

I'm working on a document with 40 artboards.
When using any of the export commands, Sketch crashes. I've seen there might be some problems when files aren't saved but mine is.

Thanx!
Ester

Change default shortcut to move an object 100px

The option+shift+arrow default shortcut interferes with the OS-level text-selection shortcut. option+shift+arrow[left/right] selects the word to the right or left of the cursor. I use this a lot when renaming layers and artboards.

The default Sketch Commands shortcut interferes with this and it’s pretty annoying. I can imagine other people have this problem too.

File dialog can return badly-formed paths

Using the file dialog in ways such as this:
[doc askForUserInput:"Export to…" ofType:2 initialValue:file_path]
can return paths that start with file://, which is not acceptable for the com.bomberstudios.export_all_* functions.

This was observed on OSX 10.9.4, Sketch Version 3.0.4 (8053) and specifically for folders on the Desktop.

This should probably handled in a standard way.

Export page

Hi. I'm sorry if this has been asked before, but is it possible to export all the artboards in the current page as a single file, the way they are presented on the screen?

Say, when I want to show all the artboard on a single page to a client. Is it possible at all?

Export Artboards from all pages

I was wondering if there could be a command that exports all artboards for all pages at once. Also it should make sure that it renames the export so that similarly named artboards don't get crushed on export.

Thx!

Script request - Center all pages

Hi there,

Here's a common issue. The Sketch guys still haven't figured out a good way to synchronize the canvas position across all pages, which means when you want to present your work or look at it to compare screens, the canvas jumps all over the place, rendering it unusable.

I was wondering if there was a way to align all the pages in one command. Right now, I have to do: (page down + center canvas + 100% actual size) x the number of pages. Which is super annoying, especially because I have to do it as soon as I move the canvases around.

Cycling through pages and centering and resizing would be awesome. I tried looking into scripting myself but I'm having trouble understanding it.

Reordering Artboards in Layer list

Hey there,

first of all thanks a lot for providing these very useful commands for Sketch!
Very helpful in our everyday work.

I have something in my mind since quite some time that I think would totally enhance our workflow. It might be pretty specific, and the solution I have in mind not really possible with Sketch's current API, but I thought I just write it down here to start a conversation …

We're working with a lot of Artboards per Page. This happens both while exploring a broad range of drafts (duplicating Artboards for new iterations), but also when documenting our design. We're taking some time to refactor our documents every now and then – mostly manually order the Artboards on the Canvas from the upper left to the lower right.

Now the problem: we usually have a pretty well structured Canvas, upper left to lower right. But this –for sure– is not at all reflected in the Layer List (new/duplicated Artboards being added on top of currently selected Artboard -> layer model). So I was thinking if we have this clear order of Artboards on the Canvas, wouldn't it be great to have a command to re-order the Artboards representations in the Layer List accordingly? (First Artboard top left becomes first in the Layer List etc.)

(Also, it would be great to be able to expand/collapse all Artboards/Groups in the Layer List at once by pressing a modifier, just like in Photoshop – but I'm aware this is something that should be part of Sketch itself ;-)

Do you know what I mean? Looking forward to your thoughts!

Have a great Sunday,
Christophe

Export layers to PSD

Could there be some sort of script that took all your current layers within a slice and exported at least the png version into a PSD organised correctly with their position and size? Layer styles would be an awesome plus but I'm not even sure if any sort of program could have permissions to export to psd.

Thanks guys!

Script don't work unless the file has been saved.

All the plugins that use the common.js library seem to not work unless you save the file first.

The reported error in the console is Sketch[55304:707] JSException: TypeError: 'null' is not an object (evaluating 'file_url. path') on line 9 of (null)

Export does not works

Hi,

no export does not work with my version 2.2.4 (242), purchased on App store

Thx

Clear All Guides

Seing how difficult it is to manually remove guides, a collection of command to remove All / Vertical / Horizontal guides would be most welcome.

Update project structure to follow new Sketch plugin guidelines

Inspired by this repo, I'm creating my own commands and most of them have been borrowed from yours so, if you're interested, I can create a PR to update this repo structure. Some of these changes would be:

  • Replace .jstalk by .cocoascript
  • Create a .sketchplugin folder
  • Add a manifest.json file
  • Add a nodeJS task to update manifest.json when new files are added or updated into the sketch plugin folder

Numberize: Artboards, Pages, Slices

It would be nice to have commands to add / remove numbers in Artboard / Page / Slice (even Layer) names.

This is requested on #18, see there for more context.

Not working "Move..." commands in 3.4

Moving commands don't work after 3.4 sketch update.

Update: As it turned out, sketch 3.4 works tricky with selection variable if several sketch files are opened

Not working in Yosemite

Plugin doesn't seem to be working after updating to Yosemite. Maybe its just me, not sure though.

Getting this in console.app "10/23/14 12:16:52.207 AM All Slices as PDF (Sketch Plugin)[406]: AppSandboxFileAccessPersist.keyForBookmarkDataForURL(file:///Users/colemantharp/Dropbox/Projects/Coleman%20Tharp/PROJECT/iOS/)" when trying to export all artboards as PNG.

Is there anyway to fix this?

Select text layers crashes Sketch 3

Not quite sure why - tested on a small project and it worked fine.
With one of my larger projects Sketch bombs - here's the log from my console. The marker in the log was added just prior to executing the command so everything after is a result of running the script.

25/10/2014 22:03:15.181 Console[29277]: Marker - 25 Oct 2014 22:03:15
25/10/2014 22:03:30.207 Sketch[29581]: 1 0x7fff848a07f6 cti_op_call_NotJSFunction
25/10/2014 22:03:30.207 Sketch[29581]: 2 0x472d566121a9
25/10/2014 22:03:30.207 Sketch[29581]: 3 0x7fff84720ba6 JSC::Interpreter::execute(JSC::ProgramExecutable_, JSC::ExecState_, JSC::JSObject_)
25/10/2014 22:03:30.208 Sketch[29581]: 4 0x7fff8471f9a6 JSC::evaluate(JSC::ExecState_, JSC::SourceCode const&, JSC::JSValue, JSC::JSValue_)
25/10/2014 22:03:30.208 Sketch[29581]: 5 0x7fff8471f69d JSEvaluateScript
25/10/2014 22:03:30.208 Sketch[29581]: 6 0x10d2d0725 -[Mocha evalJSString:scriptPath:]
25/10/2014 22:03:30.208 Sketch[29581]: 7 0x10d2d0639 -[Mocha evalString:atURL:]
25/10/2014 22:03:30.208 Sketch[29581]: 8 0x10d2d4848 -[COScript executeString:baseURL:]
25/10/2014 22:03:30.208 Sketch[29581]: 9 0x10ceec0df
25/10/2014 22:03:30.208 Sketch[29581]: 10 0x10ce5ad8a
25/10/2014 22:03:30.208 Sketch[29581]: 11 0x10ce59e3d
25/10/2014 22:03:30.209 Sketch[29581]: 12 0x7fff8b78a260 -[NSApplication sendAction:to:from:]
25/10/2014 22:03:30.209 Sketch[29581]: 13 0x7fff8b7a51c8 -[NSMenuItem corePerformAction]
25/10/2014 22:03:30.209 Sketch[29581]: 14 0x7fff8b7a4f04 -[NSCarbonMenuImpl performActionWithHighlightingForItemAtIndex:]
25/10/2014 22:03:30.209 Sketch[29581]: 15 0x7fff8b7f440d -[NSMenu internalPerformActionForItemAtIndex:]
25/10/2014 22:03:30.210 Sketch[29581]: 16 0x7fff8b7f4289 -[NSCarbonMenuImpl carbonCommandProcessEvent:handlerCallRef:]
25/10/2014 22:03:30.210 Sketch[29581]: 17 0x7fff8b79aff6 NSSLMMenuEventHandler
25/10/2014 22:03:30.210 Sketch[29581]: 18 0x7fff84fa91d4 DispatchEventToHandlers(EventTargetRec
, OpaqueEventRef
, HandlerCallRec
)
25/10/2014 22:03:30.210 Sketch[29581]: 19 0x7fff84fa8787 SendEventToEventTargetInternal(OpaqueEventRef_, OpaqueEventTargetRef_, HandlerCallRec_)
25/10/2014 22:03:30.210 Sketch[29581]: 20 0x7fff84fbc880 SendEventToEventTarget
25/10/2014 22:03:30.210 Sketch[29581]: 21 0x7fff84ff2640 SendHICommandEvent(unsigned int, HICommand const_, unsigned int, unsigned int, unsigned char, void const_, OpaqueEventTargetRef_, OpaqueEventTargetRef_, OpaqueEventRef__)
25/10/2014 22:03:30.211 Sketch[29581]: 22 0x7fff85025228 SendMenuCommandWithContextAndModifiers
25/10/2014 22:03:30.211 Sketch[29581]: 23 0x7fff850251d0 SendMenuItemSelectedEvent
25/10/2014 22:03:30.211 Sketch[29581]: 24 0x7fff850250af FinishMenuSelection(SelectionData_, MenuResult_, MenuResult_)
25/10/2014 22:03:30.211 Sketch[29581]: 25 0x7fff8502d085 MenuSelectCore(MenuData_, Point, double, unsigned int, OpaqueMenuRef__, unsigned short_)
25/10/2014 22:03:30.211 Sketch[29581]: 26 0x7fff8502ccb1 _HandleMenuSelection2
25/10/2014 22:03:30.211 Sketch[29581]: 27 0x7fff8b70d62c _NSHandleCarbonMenuEvent
25/10/2014 22:03:30.212 Sketch[29581]: 28 0x7fff8b56c52e _DPSNextEvent
25/10/2014 22:03:30.212 Sketch[29581]: 29 0x7fff8b56b89b -[NSApplication nextEventMatchingMask:untilDate:inMode:dequeue:]
25/10/2014 22:03:30.212 Sketch[29581]: 30 0x7fff8b55f99c -[NSApplication run]
25/10/2014 22:03:30.212 Sketch[29581]: 31 0x7fff8b54a783 NSApplicationMain
25/10/2014 22:03:31.378 _securityagent[29628]: audit warning: allsoft
25/10/2014 22:03:31.378 _securityagent[29627]: audit warning: soft /var/audit
25/10/2014 22:03:31.380 _securityagent[29629]: audit warning: closefile /var/audit/20141025210259.20141025210331
25/10/2014 22:03:31.497 com.apple.launchd.peruser.505[191]: (com.bohemiancoding.sketch3.6016[29581]) Job appears to have crashed: Segmentation fault: 11
25/10/2014 22:03:31.712 ReportCrash[29623]: Saved crash report for Sketch[29581] version 3.1 (8751) to /Users/xxxxxxxx/Library/Logs/DiagnosticReports/Sketch_2014-10-25-220331_xxxxxxxxxxx-MacBook-Pro.crash

All Artboards In Page leaves artboards in other pages selected

The current plugin for All Artboards In Page does deselect everthing in the current page before selecting all artboards. However it keeps the selected layers in other Pages in the same document.

I use the plugin to select all artboards in this page for exporting to a particular folder for the page.

Thanks in advance ;)

Corner Radius plugin

It sets the value correctly but Sketch doesn't render the changes until the radius slider is dragged upon.

Export: All artboards as PNG

This use to create folders for each Page that the document had. It's not working for me anymore. I'm able to export the artboard from the current Page but doesn't create the folders like it use to.

Plugins not working in Sketch 2.3 Beta

Most, if not all, of the sketch commands plugins aren't working in the latest Sketch 2.3 beta (3898). There may be some underlying changes made to Scripting in 2.3, but I don't see documentation for any changes, yet.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.