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

Objects are being selected when they shouldn't compared to doing it manually

New Here ,
Oct 02, 2025 Oct 02, 2025

Manually: I have one object(Main Piece). I duplicate it onto another layer (UG_OG). I use the "off_neg_1_16in" action I have. It selects the offset piece(Offset Piece) and nothing else. I change the spot color tent to 100%. End result is perfect.

Script: Does everything but after the action it still has everything selected and changes the color for all of them. End result is inncorrect. I should note it only does the offset on the UG_OG piece which is what I want. So im even more confused as to how the other 2 pieces are still selected

So even though after it does the action it should technically only have 1 object selected but has all 3 pieces selected. Are you suppose to deselect objects in the script every single time? I thought it would do this automatically if true?


I put safe guards in place to only change what I want but I was wondering if im doing something wrong? Why and How is a script completely different than doing it manually? 

Script doesn't show safe guards btw.

var ogPieces = [];
  for (var i = 0; i < paKOpieces.length; i++) {
    var og = paKOpieces[i].duplicate(REDLayer, ElementPlacement.PLACEATBEGINNING);
    og.name = "_UG_OG_" + i;
    setFill(og, "RED", 50);
    ogPieces.push(og);
    info("Created OG piece " + i);
  }

  app.selection = null;
  for (var j = 0; j < ogPieces.length; j++) {
    ogPieces[j].selected = true;
  }

  info("Running offset");
  runAction(ACT.off_neg_1_16in);

  if (app.selection && app.selection.length > 0) {
    for (var o = 0; o < app.selection.length; o++) {
      var item = app.selection[o];
      setFill(item, "RED", 100);
    }
  }


 

Have a wonderful day
TOPICS
Scripting
89
Translate
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

Participant , Oct 02, 2025 Oct 02, 2025

ahh, misunderstood what the offset action was doing. 

it may be helpful to add a deselect scriptline in and/or an app.redraw. There are sometimes odd behaviors that happen when the background has not updated to what the script is doing. 

Translate
Adobe
Participant ,
Oct 02, 2025 Oct 02, 2025

without seeing the specifics of the action and the rest of the script its hard to say. Is there a reason you have to use an action for this? This sounds like something a script could handle on its own without mixing an action into the process.

Translate
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
New Here ,
Oct 02, 2025 Oct 02, 2025

I tried making it without an action but just kept running into issue that I couldn't figure out why it was doing what it was doing (Ex: did Line Joint: bevel instead of Line Joint: miter even though manaully doing it works fine). So, I went with an action as it was more stable and easier to work with.

The action does Object->Path->Offset Path with it having preselected values for the Offset, Miter Limit and Line Joint

The rest of the code is irrilevent as paKOpieces has only one object and setFill() specifically only changes the color of the object. Debugging shows that after it calls the action (and only after), it has all 3 pieces selected. Even though manually replicating it shows that I have one object selected. I was just curoius as to why that is but it seems like one of those weird illustrator things.

Have a wonderful day
Translate
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
Participant ,
Oct 02, 2025 Oct 02, 2025

ahh, misunderstood what the offset action was doing. 

it may be helpful to add a deselect scriptline in and/or an app.redraw. There are sometimes odd behaviors that happen when the background has not updated to what the script is doing. 

Translate
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
New Here ,
Oct 02, 2025 Oct 02, 2025
LATEST

Yeah, I'll just have to do that. Appreciate your help

Have a wonderful day
Translate
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