Copy link to clipboard
Copied
Hello,
I want to apologize in advance for my English, because I use a translator and do not know if it will be correct.
I would like to have two different scripts but I do not know how to do it.
The first will be a script that isolates the visible texts in the same layer and if possible that duplicates it and vectorizes the new layer.
I already managed to find this:
But it takes into account all the texts except the locked ones and creates an error if a text is locked.
For the second, I have unfortunately found nothing.
I would like a script that displays the result of the Width / Height and Height / Width calculation of the selected block.
I thank everyone in advance who will take the time to help me.
Try the following version
...var myDoc = app.activeDocument
var layers = myDoc.layers.everyItem().getElements()
if(!myDoc.layers.itemByName("textLayer").isValid){myDoc.layers.add({name:"textLayer"})};
var textLayer = myDoc.layers.itemByName("textLayer");
var lockedLayers = []
for(var i = 0; i < layers.length; i++)
{
if(layers.name == "textLayer" || layers.visible == false)
continue;
//Collect all the layers that are locked and unlock them
if(layers.locked == true)
{
Copy link to clipboard
Copied
Hi Kyvarit,
I used your script and it works fine for me with locked text frames as well. However it will give an error in case the textframes are placed on a locked layer. Can you share the error message that you get, also can you run your tests to see whether any layer in your document is locked. You could also share the document that gives you error by uploading it on Dropbox and pasting the public layer here
In order to unlock layers on which these text elements are placed you could use a code like below
var layers = myDoc.spreads.everyItem().textFrames.everyItem().itemLayer
Then you could iterate over all the elements in layers array, set their locked property to false and then try to change their layer to the new layer you are creating
-Manan
Copy link to clipboard
Copied

In my case, whether it is the layer or the texts that are locked, I have this error.
There are two problems with my script.
1 / It blocks on blocks / layers locked.
2 / It does not ignore the invisible layers, so I can find myself with non-visible texts made visible during the execution of the script.
Copy link to clipboard
Copied
For me it works as i mentioned. Can you share a sample document? Upload it on Dropbox or any such cloud service and post the public URL here.
-Manan
Copy link to clipboard
Copied
Try the following code, it should work as per my description above. I have made provisions to avoid moving textframes from layers which are invisible. The logic is explained via comments in the code
var myDoc = app.activeDocument
var layers = myDoc.layers.everyItem().getElements()
if(!myDoc.layers.itemByName("textLayer").isValid){myDoc.layers.add({name:"textLayer"})};
var textLayer = myDoc.layers.itemByName("textLayer");
var lockedLayers = []
for(var i = 0; i < layers.length; i++)
{
if(layers.name == "textLayer" || layers.visible == false)
continue;
//Collect all the layers that are locked and unlock them
if(layers.locked == true)
{
lockedLayers.push(layers)
layers.locked = false
}
var pi = layers.allPageItems //Pageitems present on the layer
for(var j = 0; j < pi.length; j++)
{
if(pi
.constructor.name != "TextFrame" || pi .parent.constructor.name == "Character") //Avoid pageitems other than textframe or inline textframes continue;
pi
.locked = false pi
.itemLayer = textLayer }
}
//Lock the layers that were originally locked
for(var i = 0; i < lockedLayers.length; i++)
lockedLayers.locked = true
-Manan
Copy link to clipboard
Copied
Thank you it's great! I can read the script and comments, I do not understand much ^^,
If anyone has an idea for the second script.
Copy link to clipboard
Copied
here is the link :
https://drive.google.com/open?id=1qnYJ9SZEj-Se6L3GtYBnDewHxkfd6LpD
Copy link to clipboard
Copied
I tried the script i gave above on the document and it works fine. Try it
-Manan
Copy link to clipboard
Copied
So I'm having a new problem.
There is an error number "30615" that occurs when there is a text block grouped with another block (text or not)
I changed the text file. with all the tests I did, it was no longer correct.
In any case already thank you, because it is already a very big progress for me this script.
Copy link to clipboard
Copied
What is required when the we have a textframe within a group, should the whole group move to the new layer or the group ungrouped and the textframe moved to the new layer. How about nested groups, how should they be handled.
-Manan
Copy link to clipboard
Copied
The goal for me and to have the isolated texts on the same layer in order to be able to vectorize them quickly while keeping a copy of the layer for modification.
So in any case, I would like visible text objects to be on the same layer.
Copy link to clipboard
Copied
Try the following version
var myDoc = app.activeDocument
var layers = myDoc.layers.everyItem().getElements()
if(!myDoc.layers.itemByName("textLayer").isValid){myDoc.layers.add({name:"textLayer"})};
var textLayer = myDoc.layers.itemByName("textLayer");
var lockedLayers = []
for(var i = 0; i < layers.length; i++)
{
if(layers.name == "textLayer" || layers.visible == false)
continue;
//Collect all the layers that are locked and unlock them
if(layers.locked == true)
{
lockedLayers.push(layers)
layers.locked = false
}
var pi = layers.allPageItems //Pageitems present on the layer
for(var j = 0; j < pi.length; j++)
{
if(pi
.constructor.name != "TextFrame" || pi .parent.constructor.name == "Character") //Avoid pageitems other than textframe or inline textframes continue;
while(pi
.parent.constructor.name == "Group") pi
.parent.ungroup() pi
.locked = false pi
.itemLayer = textLayer }
}
//Lock the layers that were originally locked
for(var i = 0; i < lockedLayers.length; i++)
lockedLayers.locked = true
-Manan
Copy link to clipboard
Copied
Thank you very much Manan!
It works very well.
Get ready! An upgraded Adobe Community experience is coming in January.
Learn more