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

Help! artlayer.textItem returns undefined when asked for a valid property like baselineShift

Community Beginner ,
Jan 15, 2015 Jan 15, 2015

Copy link to clipboard

Copied

This is driving me nuts:
When asking for a property of a textItem like baselineShift, and that property has not been manually set by the user before, it returns undefined even though it may have a default value, as evidenced in the Character properties panel. Is there a workaorund to this bug?

To replicate:

• Put a paragraph style textfield into your document

• Put in some text

• Do not change any of the default values

• alert(app.activeDocument.activeLayer.textItem.baselineShift)

[ result: undefinded]

• Now set the baseline shift in the properties panel to say 15

• alert(app.activeDocument.activeLayer.textItem.baselineShift)

[ result: 15 px]

TOPICS
Actions and scripting

Views

245

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
Adobe
Community Expert ,
Jan 16, 2015 Jan 16, 2015

Copy link to clipboard

Copied

You could wrap the code in a try-clause and return the default value on error.

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 Beginner ,
Jan 16, 2015 Jan 16, 2015

Copy link to clipboard

Copied

True,and thanks for the workaround.

But so sad that Adobe is so sloppy about it and does not clean up their act or at least document these flaws.

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
Enthusiast ,
Jan 16, 2015 Jan 16, 2015

Copy link to clipboard

Copied

LATEST

When working with textItem properties it's good practice to always wrap access and have default value (and maybe user warnings), it can just blow up For example sometimes accessing justification gets in a bad state and only help is resetting the setting in UI.

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