Skip to main content
Participating Frequently
April 2, 2014
Answered

"Isolation Mode" and Javascript.

  • April 2, 2014
  • 1 reply
  • 7839 views

Hi All,

Does anyone know of a way to get out of IsolationMode using Javascript?

I am trying to create a Duplicate of a Selection on a Tempory Layer.

The selection is often quickest to get to by Isolating.

Then running script.

I'm getting this error:

Error 9034: Cannot add a new layer as sibling to 'Isolation Mode' synthetic layer.

->  tempLayer = app.activeDocument.layers.add();

I also have this issue with another Script I use to Save Artwork.

If Isolation Mode is active when script is run, file is saved with non-isolated sections "Dimmed"

Would be nice to "Idiot Proof" the code a little more by getting out of Isolation mode if need be before saving.

Snippet of save code below:

saveName = new File(FilePathAndName);

saveOpts = new PDFSaveOptions();

saveOpts.compatibility = PDFCompatibility.ACROBAT5;

saveOpts.generateThumbnails = true;

saveOpts.preserveEditability = true;

app.activeDocument.saveAs( saveName, saveOpts );

Fingers Crossed there is a way to access "Isolation Mode" using Javascript.

Both scripts are too much for an action.

I can't run action from Javascript... can I? (boo)

and I realy don't want to go down the path of running JS from an Action, then calling VB to call a different action bla bla.

am using CS6 with CC coming soon...

Thanks in advance...

This topic has been closed for replies.
Correct answer Silly-V

Yea, turns out, you can save the document! The downside is the upside.

Or, another insane way to try to workaround this, is to record a platform-specific script which you can either write to disk and execute, or manually write and then execute, which will simply send keys to activate the Illustrator's Exit Isolation Mode keyboard shortcut (which you have to assign in keyboard shortcuts), and it will exit the isolation mode. I just tested on Windows, and it worked, even performing actions after exiting the isolation mode.

The same thing can also be done in an equally hefty way, by recording an action that does the same thing ( if possible), and running that from the script in CS6+.  But, I think the problem with actions is that they don't unload when you tell them to?*

Anyways, if you consider executing an external file from extendscript that can punch in the key shortcut as being from "within extendscript", then, the answer is yes, if you want to do something along the lines of the following code:

#target illustrator

function test(){

    var doc = app.activeDocument;

   var scpt = File("C:\\Users\\User\\Desktop\\test_SendKeys.vbs");

   scpt.execute();

 

   //Stuff afterwards

   var fc = new CMYKColor;

   fc.cyan = 0;

   fc.magenta = 100;

   fc.yellow = 100;

   fc.black = 0;

   doc.pathItems[0].fillColor = fc;

}

test();

And the test_SendKeys.vbs file is this:

Set WshShell = WScript.CreateObject("WScript.Shell")

WshShell.SendKeys "%^(9)"

As my shortcut for exiting Isolation Mode is Ctrl+Alt+9 , I send those keys using the sendkeys | VBScript | SS64.com syntax described there.

EDIT: Forget all this, if you are on CS6+, see next post for CS6+ solution.


Okay, for those fortunate to have CS6+ Illustrator, this approach may be a possible workaround since it's cross-platform, and needs to use no pre-programmed shortcut keys as Exit Isolation Mode is recordable from the Layers fly-out menu.

It'll use the layer's name to try and determine if we are currently in isolation mode by the layer's name being "Isolation Mode".  So if there's normal layers named that, it'll be a problem. In addition, it's possible to load an entire action set from a file into the Actions palette, and it is possible to unload one action at a time from it, but I don't see a way to delete an entire set. Therefore, this method will always leave a trace on the user Application: an action set called "TEST1".

#target illustrator

function test(){

    if(app.documents.length > 0){

        var doc = app.activeDocument;

        if(doc.layers[0].name == "Isolation Mode"){

            app.userInteractionLevel = UserInteractionLevel.DONTDISPLAYALERTS;

            try{

                app.doScript("Action 1", "TEST1", false);

                if(doc.layers[0].name == "Isolation Mode"){

                    throw new Error("The Exit Isolation Mode action did not successfully play. It may be absent.");

                }

            } catch(e){

                var exitIsolationModeAction = "/version 3"+

                "/name [ 5"+

                " 5445535431"+

                "]"+

                "/isOpen 1"+

                "/actionCount 1"+

                "/action-1 {"+

                " /name [ 8"+

                " 416374696f6e2031"+

                " ]"+

                " /keyIndex 0"+

                " /colorIndex 0"+

                " /isOpen 1"+

                " /eventCount 1"+

                " /event-1 {"+

                " /useRulersIn1stQuadrant 0"+

                " /internalName (ai_plugin_Layer)"+

                " /localizedName [ 5"+

                " 4c61796572"+

                " ]"+

                " /isOpen 0"+

                " /isOn 1"+

                " /hasDialog 0"+

                " /parameterCount 1"+

                " /parameter-1 {"+

                " /key 1836411236"+

                " /showInPalette -1"+

                " /type (integer)"+

                " /value 25"+

                " }"+

                " }"+

                "}";

                var temp = File(Folder.desktop+"/ExitIsolationModeActionFile.aia");

                temp.open('w');

                temp.write(exitIsolationModeAction);

                temp.close();

                app.loadAction(temp);

                app.doScript("Action 1", "TEST1", false);

            }

        }

    }

}

test();

1 reply

Larry G. Schneider
Community Expert
Community Expert
April 3, 2014

For CS6 and above you can run an action using ExtendScript.

accidental_PhD
Participant
November 20, 2014

Any clues as to what action we should run to get out of Isolation Mode?

Larry G. Schneider
Community Expert
Community Expert
November 20, 2014

Edit your Keyboard shortcuts to add a shortcut for the Exit Isolation Mode. You can then Record the use of the shortcut in an action using Insert menu command from the flyout.