• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Path not selected when added

Engaged ,
Apr 07, 2021 Apr 07, 2021

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;  
    } 
}

 

 
TOPICS
Scripting

Views

259

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Apr 07, 2021 Apr 07, 2021

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;
}

 

Votes

Translate

Translate
Adobe
Participant ,
Apr 07, 2021 Apr 07, 2021

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;
}
}
}

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
Apr 07, 2021 Apr 07, 2021

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?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Apr 07, 2021 Apr 07, 2021

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;
}

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Apr 07, 2021 Apr 07, 2021

Copy link to clipboard

Copied

LATEST

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines