I’m looking for someone who can create for me a Sketch Plugin that can do the following tasks in sequence when a Text is selected:
- Convert to Outlines
- Ungroup the Folder it created
- Combine the Shapes
- Name the Shape Layer the Same name as the Text
I’m looking for someone who can create for me a Sketch Plugin that can do the following tasks in sequence when a Text is selected:
I can recommend someone. I’ll send you a DM in a bit.
Perfect! Thanks
Try this in the Run Script area within Sketch…
const sketch = require("sketch")
const document = sketch.getSelectedDocument()
const documentData = document.sketchObject.documentData()
const actionsController = document.sketchObject.actionsController()
var outlineAction = actionsController.actionForID("MSConvertToOutlinesAction")
var ungroupAction = actionsController.actionForID("MSUngroupAction")
var unionAction = actionsController.actionForID("MSUnionAction")
var selections = document.selectedLayers
var selection = selections.layers[0]
if (selections.length != 1 || selections.length == 1 && selection.type != 'Text') {
sketch.UI.alert('Convert text to outline','Select one text layer')
return
}
let textValue = selection.text
if (outlineAction.validate()) outlineAction.performAction(nil)
if (ungroupAction.validate()) ungroupAction.performAction(nil)
if (unionAction.validate()) unionAction.performAction(nil)
document.selectedLayers.layers[0].name = textValue
sketch.UI.message('Text converted')
If it works for your needs, save click the Save Script As Plugin in the Run Script window, give it a name, and you are off to the races.
Oh man this worked great! Thank you soooooo much! Great work! This is probably the most tedious part of my design work.
One more tiny favor: Would you be able to update the script such that I can Multiple Select different Text at the same time? If not that’s fine.
I had a feeling you might ask for that. I will take another look if/when I get a moment.
HAHA…Well what you created will already save me tons of work, so don’t feel obligated. It’s already much appreciated! I’m already working and using it now.
Give this a try…
const sketch = require("sketch")
const document = sketch.getSelectedDocument()
const documentData = document.sketchObject.documentData()
const actionsController = document.sketchObject.actionsController()
const selections = document.selectedLayers
var outlineAction = actionsController.actionForID("MSConvertToOutlinesAction")
var ungroupAction = actionsController.actionForID("MSUngroupAction")
var unionAction = actionsController.actionForID("MSUnionAction")
if (selections.length == 0) {
sketch.UI.alert('Convert text to outline','Select at least one text layer')
return
}
var convertCount = 0
selections.forEach(selection => {
if (selection.type == 'Text') {
selection.sketchObject.select_byExtendingSelection(true,false)
let textValue = selection.text
if (outlineAction.validate()) outlineAction.performAction(nil)
if (ungroupAction.validate()) ungroupAction.performAction(nil)
if (unionAction.validate()) unionAction.performAction(nil)
document.selectedLayers.layers[0].name = textValue
convertCount++
}
})
sketch.UI.message(`${convertCount} text converted`)
Yep this did it! Thanks again! Much appreciated!