newsdev / ai2html

A script for Adobe Illustrator that converts your Illustrator artwork into an html page.
http://ai2html.org
Other
898 stars 146 forks source link

Feature request: Option to not modify ai file #149

Closed lajoiemedia closed 1 year ago

lajoiemedia commented 2 years ago

There should be an option that causes ai2html to use the settings file exclusively and not modify the original ai file.

This would be useful especially when batch running ai2html.

mbloch commented 2 years ago

This seems like a good suggestion, I'll look into how best to implement it.

I'm curious, how are you batch running ai2html? I've only run it interactively, via the File > Scripts menu.

lajoiemedia commented 2 years ago

I have a node script which runs through all the AI files in a directory and calls something like this:

const child = require("child_process");
const AI2HTML_SCRIPT = "path/to/ai2html.js";

function doConversion(file) {
  try {
    child.execSync(`osascript -e 'tell application id "com.adobe.illustrator"
        activate
        open POSIX file "${file}" without dialogs
        do javascript file "${AI2HTML_SCRIPT}"
      end tell'`);
  } catch(e) {
    console.error(`Failed to convert ${file}`);
    process.exit(-1)
  }
}

This works only on Mac and was lifted from ai2react-loader from AP's Andrew Milligan (https://github.com/andrewmilligan/ai2react-loader/blob/main/src/index.js)

There's a single config file that sits in the directory with all my AI files. I want that config to determine how all the AI files are converted. Unfortunately, if I make a change to that config file, any files that have already run through the process are going to ignore the settings change (because they now have a block which overrides those settings).

mbloch commented 1 year ago

Sorry this took so long... I added an option named create_settings_block, which can be set to false in an ai2html-config.json file if you want to prevent creation of a text block for settings.

lajoiemedia commented 1 year ago

That's awesome! Thanks for that.