Copy link to clipboard
Copied
Dear community,
I've written a small script which transforms text to outline and afterwards unites the paths via pathfinder. This works as intended when ran via File > Scripts. However, when I run the script via an action the text-path group isn't selected and thus pathfinder doesn't work.
var docRef = app.activeDocument;
var textFrames = docRef.textFrames;
// Failsafe
if (textFrames.length != 0) {
text_to_path_and_unite(textFrames);
}
// Text to path and unite path
function text_to_path_and_unite(textFrames) {
while (textFrames.length != 0) {
// Deselect all layers
app.executeMenuCommand("deselectall");
// Select text && transform to path
textFrames[0].selected = true;
textFrames[0].createOutline();
// Unite path via pathfinder
app.executeMenuCommand("group");
app.executeMenuCommand("Live Pathfinder Add");
app.executeMenuCommand("expandStyle");
}
}
Any suggestions on how to select the text-path group is appreciated.
Thanks in regards.
Copy link to clipboard
Copied
Hi Muurstickerstunter,
can you post a small sample document where your code went wrong?
Also one with the desired result.
I'd like to test something…
Thanks,
Uwe Laubender
( Adobe Community Professional )
Copy link to clipboard
Copied
Hi Muurstickerstunter,
tested your code on a very simple Illustrator document with some text frames on the artboard.
It ran without any problems.
Before:
After the script run:
When nothing is selected:
So I think we need a sample file from you where you see an issue.
Regards,
Uwe Laubender
( Adobe Community Professional )
Copy link to clipboard
Copied
textFrames[0].createOutline() should return a group if the text frame is not empty.
So the following code will grab the group and select it:
// Select text && transform to path
textFrames[0].selected = true;
var returnedGroup = textFrames[0].createOutline();
returnedGroup.selected = true;
See DOM documentation:
https://www.indesignjs.de/extendscriptAPI/illustrator-latest/#TextFrameItem.html#d1e59890__d1e60312
However, I think we can run into issues if a text frame is empty.
In that case, should the script do something to a frame like that?
If you still try to createOutlines() on an empty frame you will provoke an info message to the user.
To tackle this you have to set the app.userInteractionLevel to value UserInteractionLevel.DONTDISPLAYALERTS and set it back again after all text frames are visited and converted. The empty ones will be missing after that!
Note: If you prevent the function to work at all with empty text frames, you will get into deep trouble with your while loop, because the number of text frames in the document will never become zero. The same will be true, if Illustrator is not able to convert a frame to outlines for whatever reasons and the frame will still exist in the document after createOutlines() was done. Risky…
Regards,
Uwe Laubender
( Adobe Community Professional )
Copy link to clipboard
Copied
Dear Laubender,
Thank you for your responses and excuse me for my late reply. The script indeed runs perfectly via File > Scripts. However, it doesn't seem to run correctly via actions. At least, partly. I would like to keep the text (or rather pathfinded path) on the same layer as it was originally and seperated from each other. The main issue I run into currently is the pathfinder not working.
I have added 4 files as requested:
Please note that you might need to download the font "Great Vibes", this font overlays letters and thus shows the wished outcome. It seems to me like a script ran via the actions menu doesn't select and deselect layers properly. But this is only a hypothesis.
Also thank you for your note, I didn't think of that! I'll definitely be sure to add some kind of check when we have found the issue.
Thank you for your time.
Copy link to clipboard
Copied
Can we assume that the attached pdf files are indeed ai files?
( Because the forum software has trouble to attach ai files ?! )
Thanks,
Uwe Laubender
( Adobe Community Professional )
Copy link to clipboard
Copied
Dear Laubender,
I indeed couldn't upload .AI files. The linked .PDF files can be opened in Illustrator without any problems and preserve the file structure.
Kind regards.
Copy link to clipboard
Copied
I presume this is a bug with actions. See if this works.
app.executeMenuCommand("selectall");
app.selection = null;
var docRef = app.activeDocument;
var textFrames = docRef.textFrames;
// Failsafe
if (textFrames.length != 0) {
text_to_path_and_unite(textFrames);
}
// Text to path and unite path
function text_to_path_and_unite(textFrames) {
while (textFrames.length != 0) {
// Deselect all layers
// app.executeMenuCommand("deselectall");
// Select text && transform to path
// textFrames[0].selected = true;
// textFrames[0].createOutline();
var outline = textFrames[0].createOutline();
outline.selected = true;
// Unite path via pathfinder
// app.executeMenuCommand("group");
app.executeMenuCommand("Live Pathfinder Add");
app.executeMenuCommand("expandStyle");
app.selection = null;
}
}
Copy link to clipboard
Copied
Dear Femkeblanco,
Thank you for your response! Sadly your script doesn't seem to fix my issue. I have written a detailed response to the commenter above.
I am open to all ideas and suggestions on how to fix this issue.
Thank you in regards.
Copy link to clipboard
Copied
Hi Muurstickerstunter,
thank you very much for your sample files.
I can confirm your issue.
If I execute your script code or mine using the GUI with
File > Scripts > nameOfScript
it works as expected:
As soon as I record a new action using a menu command that points to the menu nameOfScript the result is different. The menu commands "Live Pathfinder Add" and also "expandStyle" are not executed.
Note: My guess is that we should use ExtendScript DOM commands instead of menu commands to achieve what you want. But I still cannot see any DOM support for pathfinder and expand style. I hope, I'm wrong on this…
So I am out of ideas now.
Regards,
Uwe Laubender
( Adobe Community Professional )
Copy link to clipboard
Copied
Selecting and deselecting everything at the beginning of the script (as in the script I posted) solves the problem for me, producing the same result both ways.
Copy link to clipboard
Copied
Hi @femkeblanco ,
tested your script code on my German Illustrator 2022 on Windows 10.
Running the script from menu File > Scripts > scriptname
was successful.
When I executed an action for this menu command I went into trouble.
Info message is reading:
"Now another instance of this effect will be applied. You can edit the current effect if you double-click on the effect in the Appearance panel". Blue button is reading: "Apply new effect".
If I do this and apply the new effect by pressing the blue button, the result is this:
In one case the desired result was achieved!
Not so in the other two cases.
Regards,
Uwe Laubender
( Adobe Community Professional )
Copy link to clipboard
Copied
Hi @femkeblanco ,
how exactly did you test the action?
I did it this way:
[1] Recorded the action ( at this point all was working as expected. )
[2] Closed the document without saving.
[3] Opened the document and ran the action for testing:
Here I had the issue with that Info message and the wrong result.
I also quit Illustrator, opened Illustrator again, opened the document and ran the saved action again.
This time I had no info message, but unfortunately the same wrong results:
In one case it worked, not so in the other two ones of the test document.
Regards,
Uwe Laubender
( Adobe Community Professional )
Copy link to clipboard
Copied
Hi @Laubender
I have the script in the Scripts folder, such that it appears on the list of scripts in File > Scripts. (If it was a new script, I would have had to close and open Illustrator for it to appear on the list.) To record the script in an action, I select the action in the Action panel, click the panel menu in the upper right corner, click "Insert Menu Item..." and enter the name of the script. Then I play the action. At this point, closing and opening the document shouldn't affect things.
Copy link to clipboard
Copied
Thanks. That's exactly the same that I did.
After recording and saving the action I quit Illustrator, opened it again and tested the action on the OP's test document that is attached with the wrong suffix *.pdf here:
Download the file, rename it to *.ai and you are good to go for testing. Well, had to activate a fonts style from Adobe Fonts before I actually did my tests.
That all said:
What is your localized version of Illustrator 2022 on what operating system?
Perhaps we see a difference because of that?
I'm with the German Illustrator 2022 version 26.3.1 on Windows 10.
Thanks,
Uwe Laubender
( Adobe Community Professional )
Copy link to clipboard
Copied
I'm using standard Illustrator CS6 on Windows 8.1.
You could try the simplest case: Two overlapping paths and an abbreviated script.
1. This is the script run from the editor (or File > Scripts). executeMenuCommand works and the paths unite.
2A. This is the script run from the action. executeMenuCommand doesn't work. The paths don't unite.
2B. This is the script run from the action with two added lines at the top of the script (selecting and deselecting everything). executeMenuCommand works and the paths unite.
Copy link to clipboard
Copied
Also now tried your code from:
with my German Adobe Illustrator CS6 on Windows 10.
The action recorded only a selection that was named: Alles auswählen ( "Select all" ).
The result when I ran this action was exactly like that:
Directly running the script from File > Scripts had no issues at all.
All worked as expected.
Now I wonder, that with my German version I had to access the menu actions in German perhaps?
But how can I do this? Perhaps it's impossible to run a script through an action with every localized version that is not in English, if the script contains certain menu commands?
Regards,
Uwe Laubender
( Adobe Community Professional )
Copy link to clipboard
Copied
Also did a new action from your code with the menu command added to the action in InDesign CS6.
Same result that I have seen in Illustrator 2022 on my machine. The first text frame was converted as expected. All others did not:
For now I give up on this…
Regards,
Uwe Laubender
( Adobe Community Professional )
Copy link to clipboard
Copied
Thanks for trying. There's nowhere further I can take this either.
Copy link to clipboard
Copied
Dear @Laubender & @femkeblanco,
I would like to thank you both for the amount of time you two spend on this. Sadly this does indeed seem like a bug in Adobe Illustrator.
Would any of you two know where I can report this bug to the Adobe team?
Kind regards.
Copy link to clipboard
Copied
@Muurstickerstunter said: "Would any of you two know where I can report this bug to the Adobe team?"
Go to Illustrator UserVoice, log in with a new password and your Adobe ID and write a bug report there.
Provide a link to this discussion here for all the details. Feel free to use any of my screenshots…
https://illustrator.uservoice.com/forums/601447-illustrator-desktop-bugs
Regards,
Uwe Laubender
( Adobe Community Professional )
Copy link to clipboard
Copied
Dear Laubender,
Many thanks for your response once again. I have created a post about the issue which can be found here:
Lets hope the issue will be resolved soon.
Kind regards.
Copy link to clipboard
Copied
Copy link to clipboard
Copied
Commented and voted!
Regards,
Uwe Laubender
( Adobe Community Professional )