Copy link to clipboard
Copied
Hello guys, I'm trying to create a script to add and then select an ellipse to the document, but I don't understand why it was not selected. Any help is valid.
Here the script:
addPath();
function addPath(){
var doc = app.activeDocument;
var artLayer = doc.layers[0];
var corte = artLayer.pathItems.ellipse(0, 0, doc.width, doc.height, false);
var noColor = new NoColor();
corte.fillColor = noColor;
}
selectedPath()
function selectedPath(){
var doc = app.activeDocument;
for(var i=0; i<doc.pathItems.length; i++){
doc.pathItems[i].selected = doc.pathItems[i].stroked;
}
}
I don't know why - but would you like to select (only) the newly created ellipse?
addPath();
function addPath(){
var doc = app.activeDocument;
var artLayer = doc.layers[0];
var corte = artLayer.pathItems.ellipse(0, 0, doc.width, doc.height, false);
var noColor = new NoColor();
corte.fillColor = noColor;
corte.selected = true;
}
Copy link to clipboard
Copied
try following lines
addPath();
function addPath(){
var doc = app.activeDocument;
var artLayer = doc.layers[0];
var corte = artLayer.pathItems.ellipse(0, 0, doc.width, doc.height, false);
var noColor = new NoColor();
corte.fillColor = noColor;
}
selectedPath()
function selectedPath(){
var doc = app.activeDocument;
for(var i=0; i<doc.pathItems.length; i++){
if(doc.pathItems.length>0){
doc.pathItems[i].selected =true;
}
}
}
Copy link to clipboard
Copied
Your script does select the ellipse, albeit (I presume) in an unintended way. Also, your second function is constructed to select all paths. Is that what you intended?
Copy link to clipboard
Copied
I don't know why - but would you like to select (only) the newly created ellipse?
addPath();
function addPath(){
var doc = app.activeDocument;
var artLayer = doc.layers[0];
var corte = artLayer.pathItems.ellipse(0, 0, doc.width, doc.height, false);
var noColor = new NoColor();
corte.fillColor = noColor;
corte.selected = true;
}
Copy link to clipboard
Copied
Perfect @pixxxelschubser it looks very simple. I'm new to illustrator script and I kind of improvised that script. Thank you all for your support.