Copy link to clipboard
Copied
Trying to get started with generator, but a bit confused. I've got the sample plugins running, read through other samples, searched forums, but I'm missing a basic developer guide on what is the best way to do stuff.
So general questions about Generator development:
Lots of questions and any answers are appreciated
Copy link to clipboard
Copied
The Github site is the main place you want to look. The latest Photoshop sdk has some general info on the Photoshop network API (connectionsdk), and some code samples.
There have been some additions to the APIs and the json format we use to report document info. But existing APIs should continue to work in the future (where possible). The json has a semver version to mark changes we make in newer versions.
Do's dont's .. Well I suppose mostly just follow the github project, look at the wikis, code samples, ask questions.
Temp files, there is probably a node.js/os convention for that.
Packaging, not sure. zxp is usually used for panels, you may be able to install a plugin too
There's an ExtendScript-able preference for generator enabled/disabled. You should be able to use that in a panel. Sorry, I don't have the details handy, I usually use the ScriptListener plugin to tease out ExtendScript for things I don't know.
Copy link to clipboard
Copied
Thanks,
I actually just realized the Architecture page in GitHub is not just one page but a full wiki, so that was my "missing docs" and helped me a lot You could consider putting some overview& links in the wiki home page and then linking to that in Read.me so the oblivious ones like me don't miss it..
By "ExtendScript-able preference" do you mean sending e.g. the menu event like here http://https://github.com/adobe-photoshop/generator-core/wiki/Calling-Generator-Plugins-from-ExtendS...‌? Or do you mean you could use ScriptListener to record action to enable generator and call it from panel?
Packaging sounds like I could make hybrid ZXP and use either $pluginsfolder/Generator or $photoshopappfolder/Plug-ins/Generator as the destination-parameter. Not really clear what the state would be (some doc mentioned that in "undefined" state it should be enough to copy plugin to folder. But plan is to use websockets for plugin<->panel communications, so if all else fails should be possible to detect state and instruct user what to do.
Matias
Copy link to clipboard
Copied
Generator should launch if there's 3rd party generator plugins installed, so you may not need to enable it from scripting. That menu event is supposed to launch Generator as well.
ScriptListener is just a development tool to help discover the Extendscript for a particular user action. (it has more detail than say the Actions panel for a recorded action) You can analyze the log from ScriptListener to find the correct ExtendScript calls.
I'm not as familiar with panels and .zxp, but maybe your solution would work.
Copy link to clipboard
Copied
For everyones info, this is based on the node module "tmp". It tries to search environment variables and defaults to "/tmp". At least in the standalone Node.js in Windows it resolves to C:\Users\USERNAME\AppData\Local\Temp
_findTemporaryDirectory: function () {
var tmpNames = ['TMPDIR', 'TMP', 'TEMP'];
var dir = null
for (var i = 0, length = tmpNames.length; i < length; i++) {
dir = dir || process.env[tmpNames]
}
_temporaryDirectory = dir || '/tmp'
console.log("_findTemporaryDirectory: " + _temporaryDirectory)
}
Copy link to clipboard
Copied
Just wanted to follow up that the packaging worked out as above, i.e. you can package a panel and generator plugin as a hybrid zxp using an mxi like below. Just copying the the plugin files to right directory starts geneartor automatically, so works out great.
One thing I had to look up is how to reference the plugin directory in generator code and it can be done using Node.js variable __dirname. So you can call jsx-files in the mxi like _generator.evaluateJSXFile(__dirname + "/foo.jsx").
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<macromedia-extension name="Foo Panel" id="com.yourdomain.yourapp.bundle" requires-restart="true" version="1.10.0">
<author name="Your Name"/>
<description/>
<license-agreement/>
<products>
<product familyname="Photoshop" maxversion="15.9" primary="true" version="15.0"/>
</products>
<files>
<file destination="" file-type="CSXS" products="" minVersion="15.0" maxVersion="15.9" source="panel.zxp"/>
<file destination="$photoshopappfolder/Plug-ins/Generator/ShopMyAppDesigner" file-type="ordinary" products="" source="main.js"/>
<file destination="$photoshopappfolder/Plug-ins/Generator/ShopMyAppDesigner" file-type="ordinary" products="" source="package.json"/>
<file destination="$photoshopappfolder/Plug-ins/Generator/ShopMyAppDesigner" file-type="ordinary" products="" source="foo.jsx"/>
<file destination="$photoshopappfolder/Plug-ins/Generator/ShopMyAppDesigner" file-type="ordinary" products="" source="bar.jsx"/>
</files>
</macromedia-extension>
Copy link to clipboard
Copied
Few more pointers on paths in Win & Mac:
sanitizePath: function (path) {
if (path) {
path = path.replace(/\\/gi, "/")
if (path[path.length-1] != "/") {
path = path + "/"
}
return path
}
},
Copy link to clipboard
Copied
does anyone know how to tell generator to extract all the assets to a different folder and it will do it automatically to the same folder by itself?
Copy link to clipboard
Copied
You should be able to define folder as "folder/"-prefix in your filenames
Copy link to clipboard
Copied
yes but it's only in the same folder of the psd file live. I need to save all the assets to a folder are outside of that psd file live. and it will automatically extract the assets into the same folder. do you think there is a scripts out there will do that?
Copy link to clipboard
Copied
I think that is baked in as Generator tires to be an UI-less thing. But it's open source and probably not a huge change (especially if it's just your computer you are planning).
Copy link to clipboard
Copied
As far as packaging your script, there is a packager on the Adobe Addons site that will create a zxp package. You can also post and sell it there. You can create extensions using Brackets, which setups up the basic foundation for creating an extension for you, which is nice. Davide Barranca has some tips on packaging zxp files, which I've used and is very helpful when the Addons site doesn't work well.
http://www.davidebarranca.com/2014/05/html-panels-tips-10-packaging-zxp-installers/
Copy link to clipboard
Copied
not packaging. We are talking about generator in PS.
Copy link to clipboard
Copied
I'm referring to the OP's question about creating a zxp file.