0

This is a long shot, but is there a possible way to store a JavaScript (or any sort of executable code) within an Adobe Illustrator file?

The reason I'm asking this is because I'm currently trying to automate the process of importing render results from Autodesk Maya. The concept is that as soon Maya is done rendering all frames/layers, a MEL script could generate a file that Illustrator could open and run commands found in it, directing illustrator to the render results and start importing them.

The original idea was to give a system command via MEL script to launch Illustrator straight away after rendering completion and somehow start the process. But since this automation is for not-so-tech-savvy people, an application calling for the launch of another one would be rather frustrating and maybe confusing.

Having Maya generate a file that can complete the task when the user opens it is a much preferred solution. Give more control to the user and does not overload a system that is already busy with more application calls.

Think of it like a .mel file, where upon opening, it launches the needed application (Maya) and when the application is ready, carries out the commands included (MEL). Is there a way to do that with Adobe applications, Illustrator in particular, where a file automatically is recognized as an Illustrator file (eg. .ai), launches application and then runs code contained in it (eg. JS)?

ANY help is welcomed, but I would like to avoid applescripts/VBS as they are platform specific and can be difficult to manage between Mac/Windows.

Thanks.

Falxo
  • 13
  • 5
  • This might belong on [super user](http://superuser.com). – tmthydvnprt Mar 22 '16 at 11:38
  • To sum up, you want to create a post render script that creates an .ai (or other file ext), which is embedding a script running when the file is opened? What is the goal of the embedded script? (Imho, this question is fine for this site) – DrHaze Mar 22 '16 at 13:15
  • Quite simple: After illustrator launches it will read the containing directory of where the images are located (originally at least) and start importing them one-by-one while creating new artboards for each of them. When the import loop is done, the last command would be to save the file in the same directory it was opened from. This will be easy for a less-tech-savvy user to utilize (without them having to know how to use ExtendScript or how to install scripts) and speed them up. – Falxo Mar 22 '16 at 13:26
  • Let me also add to this that I'm currently looking into doing this in EPS form (as .ai files are just that, glorified EPS) but it's extremely difficult. Advice on that front might be the way. – Falxo Mar 22 '16 at 13:31
  • What version of illustrator are you using? – DrHaze Mar 22 '16 at 13:33

1 Answers1

2

This is a relatively broad question as there can be many ways to achieve this. I'll try to give you one possible solution here, it clearly might not be the best.


Your needs:

  • Create a "file" or something that imports all the Maya's rendered images in an illustrator scene.
  • Can be executed whenever you want (No post render process that opens illustrator)
  • Non-tech people like my mom have to be able to use it.
  • Cross-platform (Win/Osx)

Solution:

  • Create a post-render script (mel or python) for Maya
  • Concerning this script (.mel or .py):
    • Is run once all frames have been rendered
    • Copies an existing JavaScript (.jsx) file in the folder where the frames have been rendered
    • Creates two executable files (.bat and .command, both for Windows and OSX)
  • Concerning the .jsx file:
    • Creates a new .ai file
    • Imports the rendered frames one by one and adds them in a new artboard
    • Saves the .ai file in the current folder
  • Concerning the .bat and .command executables:
    • Run Illustrator
    • Execute the .jsx script on startup

To sum up, once the frames will have been rendered, all three files (.jsx, .bat, .command) will be created in the same folder as the frames. When your artists will want to create their Illustrator scene, they'll just have to double click on the .bat or .command file to automatically run Illustrator and import the rendered frames and save the file.

The command to run a script on Illustrator (CS 5.1) on Windows is and this will be the content of the .bat file:

"C:\Program Files (x86)\Adobe\Adobe Illustrator CS5.1\SupportFiles\Contents\Windows\Illustrator.exe" C:\Path\To\Script.jsx

You can easily make an equivalent for the .command file.

Script.jsx can be something like this:

// Get the fullpath of the script
var script_fullpath = $.fileName
// Only get the folder path
var script_folder   = Folder(script_fullpath).path
// Get renderred frames
var rendered_frames = Folder(script_folder).getFiles("*.exr");

if(rendered_frames.length == 0){
    alert("No images to import");
}else{
    // Loop through all the images
    // Create a new artbook
    // Import Fram
    // Then save the file here: script_folder + "/" + "illustratorFile"
}
DrHaze
  • 1,318
  • 10
  • 22
  • I dont think you need the bat and cmd file as doubleclicking on the jsx file should execute it – joojaa Mar 22 '16 at 15:36
  • Ah apparently it does not work on osX, im pretty sure you can rule out user does not need to know anything without some serious engineering. – joojaa Mar 22 '16 at 15:43
  • Is it possible to run a new Illustrator instance and do all the stuff when directly executing .jsx files? I don't know much about scripting for Adobe products – DrHaze Mar 22 '16 at 15:43
  • No, adobe does only launch one process per user. But its possible to run in background as admin. – joojaa Mar 22 '16 at 15:45