Last active
September 6, 2016 04:23
-
-
Save marianomike/86fd3195d7cb468aa085bd0f5e1fdbde to your computer and use it in GitHub Desktop.
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
@import 'common.js' | |
var onRun = function(context) { | |
var doc = context.document; | |
var selection = context.selection; | |
//make sure something is selected | |
if(selection.count() == 0){ | |
doc.showMessage("Please select a layer."); | |
}else{ | |
//allow xml to be written to the folder | |
var fileTypes = [NSArray arrayWithObjects:@"xml", nil]; | |
//create select folder window | |
var panel = [NSOpenPanel openPanel]; | |
[panel setCanChooseDirectories:true]; | |
[panel setCanCreateDirectories:true]; | |
[panel setAllowedFileTypes:fileTypes]; | |
//create variable to check if clicked | |
var clicked = [panel runModal]; | |
//check if clicked | |
if (clicked == NSFileHandlingPanelOKButton) { | |
var isDirectory = true; | |
//get the folder path | |
var firstURL = [[panel URLs] objectAtIndex:0]; | |
//format it to a string | |
var file_path = [NSString stringWithFormat:@"%@", firstURL]; | |
//remove the file:// path from string | |
if (0 === file_path.indexOf("file://")) { | |
file_path = file_path.substring(7); | |
} | |
} | |
//loop through the selected layers and export the XML | |
for(var i = 0; i < selection.count(); i++){ | |
var layer = selection[i]; | |
exportXML(layer, file_path); | |
} | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment