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

Get the art item associated with a page item

Explorer ,
Dec 09, 2020 Dec 09, 2020

Copy link to clipboard

Copied

According to the documentation - "The PageItem class gives yo complete access to every art item contained in an Illustrator document." Unfortunately I cannot figure out how the art item is connected to the PageItem.

My particular case is that I want to change the contents of a textFrame. I would like to use the UUID of the pageItem to locate the textFrame. Something like this:

var pageItem = app.activeDocument.getPageItemFromUuid(uuid)
//now I want to get the textFrame so I would like to do something like this:
var textFrame = textFrame.getFromPageItem(pageItem)
textFrame.contents = "Updated value"

Any ideas would be appreciated!

 

TOPICS
Scripting , SDK

Views

420

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

Explorer , Dec 09, 2020 Dec 09, 2020

I think I figured this out. It appears that you can simply treat the pageItem like the associated art item. So the solution would be:

var pageItem = app.activeDocument.getPageItemFromUuid(uuid)
//pageItem now acts like a textFrame so we can use the textFrame properties on it
pageItem.contents = "Updated value"

Votes

Translate

Translate
Adobe
Explorer ,
Dec 09, 2020 Dec 09, 2020

Copy link to clipboard

Copied

I think I figured this out. It appears that you can simply treat the pageItem like the associated art item. So the solution would be:

var pageItem = app.activeDocument.getPageItemFromUuid(uuid)
//pageItem now acts like a textFrame so we can use the textFrame properties on it
pageItem.contents = "Updated value"

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 ,
Dec 09, 2020 Dec 09, 2020

Copy link to clipboard

Copied

pageItem and art item refer to the same thing.

 

getFromPageItem() is not a function, at least not in illustrator api

 

in your last example, you're not providing the item uuid, so your snippet shouldn't work as provided.

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
Explorer ,
Dec 09, 2020 Dec 09, 2020

Copy link to clipboard

Copied

Thanks!

Not sure why you are mentioning getFromPageItem(). I don't use that in my examples. getPageItemFromUUID was added in CC 24 (https://illustrator-scripting-guide.readthedocs.io/introduction/changelog/)

 

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 ,
Dec 09, 2020 Dec 09, 2020

Copy link to clipboard

Copied

sorry, I thought I saw it, I guess my eyes played a trick on me.

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 ,
Dec 10, 2020 Dec 10, 2020

Copy link to clipboard

Copied

LATEST

oh well, at least I know I'm not crazy.

 

getFromPageItem.PNG

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