Skip to main content
shl9066192
Participant
July 30, 2018
Resuelto

Please help to create "Unlonk All, Create Outlines, Embed" Scrpit

  • July 30, 2018
  • 3 respuestas
  • 1401 visualizaciones

Dear all, hope you enjoying everyday.

I do "Unlonk All, Create Outlines, Embed" every time after finishing my artwork.

I use action for "Unlonk All, Create Outlines" and "Embed" by manually.

Some times I need to click more than 30 times just for embed...so I tried to avoid for meaningless click.

Finally I found Embed scrpit... as below.

---------------------------------------------------------------------------------------------------------------

#target Illustrator

if ( app.documents.length > 0 ) {
  
while ( app.activeDocument.placedItems.length > 0 ) {
  placedArt
= app.activeDocument.placedItems[0];
  placedArt
.embed();
  
}
}

---------------------------------------------------------------------------------------------------------------

but I can not record script on action.

After all this situation, I'm looking for the way to create script that include

"Unlonk All, Create Outlines All(Text only but with strock is better), Embed All".

Hopefully I can got help from here.

Thank you.

Mejor respuesta de Stephen Marsh

I can’t write scripts from scratch, if I am lucky I can modify or hack simple scripts together (I have a sort of Victor Frankenstein approach), however the following appears to mostly get the job done at a very basic level. Of course, there are lots of things it does not do, so results will vary depending on the complexity of your artwork and your specific requirements.

The text to outlines bit can always be improved upon, for example I don’t know how the following AppleScript code would be re-written in JavaScript.

#target Illustrator

// My first Illustrator Script - Something to look back on and laugh at when I know better!

//

// https://forums.adobe.com/message/10531441#10531441

// https://forums.adobe.com/message/10532624#10532624

//

// https://forums.adobe.com/message/10236331#10236331

// Unlock all layers & sublayers

processLayersRecursive(app.activeDocument.layers); 

// Process all layers under variable "parent" (including sublayers on all levels). 

function processLayersRecursive(parent){  

    for (var iLayer = 0; iLayer < parent.length; iLayer++){ 

        var curLayer = parent[iLayer]; 

        // Unlock the current layer 

        if (curLayer.locked){ 

            curLayer.locked = false; 

        } 

        processLayersRecursive(curLayer.layers);      

    } 

// Unlock all objects, select all & convert text to outlines

// https://ten5963.wordpress.com/illustrator-ccver-22-menu-commands-list/

app.executeMenuCommand('unlockAll');

app.executeMenuCommand('selectall');

app.executeMenuCommand('outline');

// https://forums.adobe.com/message/10531441#10531441

// Embed all linked images

if ( app.documents.length > 0 ) {

   while ( app.activeDocument.placedItems.length > 0 ) {

  placedArt = app.activeDocument.placedItems[0];

  placedArt.embed();

   }

}

// Deselect all

app.executeMenuCommand('deselectall');

Prepression: Downloading and Installing Adobe Scripts

3 respuestas

Stephen Marsh
Community Expert
Community Expert
July 31, 2018

Of note, all of the steps can be recorded into an action, except for the “embed images” step. The code provided in the original post can be saved and recorded into an action, then you have a hybrid approach (obviously having a script is better as there are no dependencies).

shl9066192
Participant
July 31, 2018

Thank you for everything. It's more than enough.

I really appreciate all your kindness.

shl9066192
Participant
July 31, 2018

Thank you so much. It works perfectly.

Just one more... if it's possible...

After this script, can we add one more step to open 'Save As...' window?

I tried add line like below but it's not working.

app.executeMenuCommand('saveas...'); 

or

app.executeMenuCommand('saveas'); 

But it's wonderful as is now. Thank you again

Stephen Marsh
Community Expert
Community Expert
July 31, 2018

Happy to help and thank you for the feedback.

I am testing on a Mac using CS6 and CC2018 and adding the following code worked for me, I am not sure why you are having issues:

// Save as

app.executeMenuCommand('saveas');

Stephen Marsh
Community Expert
Stephen MarshCommunity ExpertRespuesta
Community Expert
July 31, 2018

I can’t write scripts from scratch, if I am lucky I can modify or hack simple scripts together (I have a sort of Victor Frankenstein approach), however the following appears to mostly get the job done at a very basic level. Of course, there are lots of things it does not do, so results will vary depending on the complexity of your artwork and your specific requirements.

The text to outlines bit can always be improved upon, for example I don’t know how the following AppleScript code would be re-written in JavaScript.

#target Illustrator

// My first Illustrator Script - Something to look back on and laugh at when I know better!

//

// https://forums.adobe.com/message/10531441#10531441

// https://forums.adobe.com/message/10532624#10532624

//

// https://forums.adobe.com/message/10236331#10236331

// Unlock all layers & sublayers

processLayersRecursive(app.activeDocument.layers); 

// Process all layers under variable "parent" (including sublayers on all levels). 

function processLayersRecursive(parent){  

    for (var iLayer = 0; iLayer < parent.length; iLayer++){ 

        var curLayer = parent[iLayer]; 

        // Unlock the current layer 

        if (curLayer.locked){ 

            curLayer.locked = false; 

        } 

        processLayersRecursive(curLayer.layers);      

    } 

// Unlock all objects, select all & convert text to outlines

// https://ten5963.wordpress.com/illustrator-ccver-22-menu-commands-list/

app.executeMenuCommand('unlockAll');

app.executeMenuCommand('selectall');

app.executeMenuCommand('outline');

// https://forums.adobe.com/message/10531441#10531441

// Embed all linked images

if ( app.documents.length > 0 ) {

   while ( app.activeDocument.placedItems.length > 0 ) {

  placedArt = app.activeDocument.placedItems[0];

  placedArt.embed();

   }

}

// Deselect all

app.executeMenuCommand('deselectall');

Prepression: Downloading and Installing Adobe Scripts