• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Generator guidelines/howto/getting started questions

Enthusiast ,
Apr 01, 2015 Apr 01, 2015

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:

  • 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

TOPICS
Actions and scripting

Views

1.6K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe
Adobe Employee ,
Apr 08, 2015 Apr 08, 2015

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Apr 08, 2015 Apr 08, 2015

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Employee ,
Apr 08, 2015 Apr 08, 2015

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Apr 10, 2015 Apr 10, 2015

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)

}

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Apr 24, 2015 Apr 24, 2015

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>

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Apr 25, 2015 Apr 25, 2015

Copy link to clipboard

Copied

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

        }

    },

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Apr 29, 2015 Apr 29, 2015

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?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Apr 29, 2015 Apr 29, 2015

Copy link to clipboard

Copied

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Apr 30, 2015 Apr 30, 2015

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?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Apr 30, 2015 Apr 30, 2015

Copy link to clipboard

Copied

LATEST

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).

adobe-photoshop/generator-assets · GitHub

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Apr 30, 2015 Apr 30, 2015

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/

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Apr 30, 2015 Apr 30, 2015

Copy link to clipboard

Copied

not packaging. We are talking about generator in PS.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Apr 30, 2015 Apr 30, 2015

Copy link to clipboard

Copied

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines