Skip to main content
matias.kiviniemi
Legend
April 1, 2015
Question

Generator guidelines/howto/getting started questions

  • April 1, 2015
  • 5 replies
  • 2027 views

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:

  • Is there any documentation beyond the GitHub-site (and here) that I'm missing?
  • Any versioning issues? It was originally launched with PS CC 14.1, but has there been "evolution"? I.e. are there things that works only in newer releases of CC (and hence the internal Node.js) or are all versions equal?
  • Any known issues, don't do's, mines I should be aware of?
  • How should you use temporary files? When the plugin would be run in the internal Node.js, where would that actually be? Can you just write temporary stuff there where ever your files happen to be lying ('./tmp/foo*')?
  • How do you package the plugin as a zxp/something for distribution?
  • Can you start the generator plugin from a panel? So can you put an on/off switch to your panel or do you have to tell users to go to File->Generator->Your plugin?

Lots of questions and any answers are appreciated

This topic has been closed for replies.

5 replies

Chuck Uebele
Community Expert
Community Expert
April 30, 2015

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/

gtang88
Participating Frequently
April 30, 2015

not packaging. We are talking about generator in PS.

Chuck Uebele
Community Expert
Community Expert
April 30, 2015

I'm referring to the OP's question about creating a zxp file.

matias.kiviniemi
Legend
April 25, 2015

Few more pointers on paths in Win & Mac:

  • Paths in Mac resolve to using "/" and in Windows "\". However in Windows you can use paths with "/", which makes operating easier. Also Mac paths come with a trailing "/" and Windows does not. Good idea to sanitize folders like below
  • Temp path in Windows resolves to "C:/Users/Username/AppData/Local/Temp/" and in Mac "something of form /var/folders/26/d_y13s7n4hj93wrqzwbd2b_00000gn/T/"
  • Plugin path in Windows resolves to "C:/Program Files/Adobe/Adobe Photoshop CC 2014/Plug-ins/Generator/PluginFolderName/" and in Mac "/Applications/Adobe Photoshop CC 2014/Plug-ins/Generator/PluginFolderName/"

sanitizePath: function (path) {

        if (path) {

            path = path.replace(/\\/gi, "/")

            if (path[path.length-1] != "/") {

                path = path + "/"

            }

            return path

        }

    },

gtang88
Participating Frequently
April 29, 2015

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?

matias.kiviniemi
Legend
April 30, 2015

You should be able to define folder as "folder/"-prefix in your filenames

matias.kiviniemi
Legend
April 24, 2015

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>

matias.kiviniemi
Legend
April 10, 2015

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)

}

Adobe Employee
April 8, 2015

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.

matias.kiviniemi
Legend
April 8, 2015

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-ExtendScript‌? 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

Adobe Employee
April 8, 2015

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.