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

Appearance Panel Stroke Visibility Scripting Issue

Engaged ,
Jun 04, 2024 Jun 04, 2024

Copy link to clipboard

Copied

So, maybe I'm missing something obvious, but I have a script that draws simple stroked rectangles based on the users selection. If the user happens to have an item selected (or was the last item selected) where the appearance panel has the stroke visibility (eyeball) turned off, any new path the script creates will also have the stroked turned off.

CleanShot 2024-06-04 at 17.48.52@2x.png

// create new path
var rect = app.activeDocument.pathItems.rectangle(circle.top - 36, circle.left, 36, 36);
rect.stroked = true;

CleanShot 2024-06-04 at 17.54.54@2x.png

I have tried changing/resetting the `defaultStroked` variables but that didn't help. The only real solution I could come up with is to create a temporaty shape, expand it's appearance, and then go on creating the shapes I need withing my script.

// create temp shape to reset appearance panel
var temp = app.activeDocument.pathItems.rectangle(0, 0, 36, 36);
app.executeMenuCommand("expandStyle");
temp.remove();

// go on creating required script shapes with appearance settings reset
var rect = app.activeDocument.pathItems.rectangle(circle.top - 36, circle.left, 36, 36);
rect.stroked = true;

CleanShot 2024-06-04 at 17.55.42@2x.png

Am I losing my ming and missing something obvious??? I also, ran into a similar issue when the selected object had multiple strokes and fill that were not in the standard order.

 

This script needs to run on unknown systems and setups so I want to ensure the shapes will be drawn correctly no matter who runs the script.

 

Thanks in advance for your help!

TOPICS
Scripting

Views

120

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 2 Correct answers

Guide , Jun 04, 2024 Jun 04, 2024

I don't know if this will help you, but applying the default graphic style will give the rectangle a visible stroke.

app.activeDocument.graphicStyles[0].applyTo(rect);

 

 

Votes

Translate

Translate
Participant , Jun 05, 2024 Jun 05, 2024

might not be ideal, but this was able to produce the results. i dont think i've ever seen someone turn off the visibility in the appearance before.

var circle = app.activeDocument.selection[0]
app.executeMenuCommand('deselectall')
var rect = app.activeDocument.pathItems.rectangle(circle.top - 36, circle.left, 36, 36);
rect.selected=true
app.executeMenuCommand('Adobe New Stroke Shortcut')
app.redraw()
rect.stroked = true;
rect.strokeWidth = 3

 

Votes

Translate

Translate
Adobe
Guide ,
Jun 04, 2024 Jun 04, 2024

Copy link to clipboard

Copied

I don't know if this will help you, but applying the default graphic style will give the rectangle a visible stroke.

app.activeDocument.graphicStyles[0].applyTo(rect);

 

 

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 ,
Jun 05, 2024 Jun 05, 2024

Copy link to clipboard

Copied

@femkeblanco, yes that was my first thougt too (sorry I should have mentioned that). I was just concerned that someone may have a custom document profile with a different default graphic style. I'm sure that is a very small chance but I was just tryig to cover all possible scenerios. Thanks as always for your help!

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
Participant ,
Jun 05, 2024 Jun 05, 2024

Copy link to clipboard

Copied

might not be ideal, but this was able to produce the results. i dont think i've ever seen someone turn off the visibility in the appearance before.

var circle = app.activeDocument.selection[0]
app.executeMenuCommand('deselectall')
var rect = app.activeDocument.pathItems.rectangle(circle.top - 36, circle.left, 36, 36);
rect.selected=true
app.executeMenuCommand('Adobe New Stroke Shortcut')
app.redraw()
rect.stroked = true;
rect.strokeWidth = 3

 

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 ,
Jun 05, 2024 Jun 05, 2024

Copy link to clipboard

Copied

LATEST

@RobOctopus, yep this works but still leaves a hidden extra stroke in the appearance panel that bugs me. I was hoping for a native way to accomplish this but I'm beginning to think there isn't one.

 

As for turning off the visibility in the actual appearance, it is something I have seen on occasion and something I do from time to time, especially with prebuilt styles. For example, in the attached image I have a prebuilt style for the name (top object), but I can easily turn off the pink accents and inner gradient to quickly achieve an alternate look without having to keep two separate styles in sync.

CleanShot 2024-06-05 at 14.39.44@2x.png

Thanks for thr suggestion!

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