Get the art item associated with a page item

Community Beginner ,
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

135

Likes

Translate

Translate

Report

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

1 Correct Answer

Community Beginner , Dec 09, 2020
Bernie5CFE Community Beginner , 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"

Likes

Translate

Translate
Jump to answer Jump to answer
Community Beginner ,
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"

Likes

Translate

Translate

Report

Report
Reply
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Adobe Community Professional ,
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.

Likes

Translate

Translate

Report

Report
Reply
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Community Beginner ,
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/)

 

Likes

Translate

Translate

Report

Report
Reply
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Adobe Community Professional ,
Dec 09, 2020

Copy link to clipboard

Copied

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

Likes

Translate

Translate

Report

Report
Reply
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Adobe Community Professional ,
Dec 10, 2020

Copy link to clipboard

Copied

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

 

getFromPageItem.PNG

Likes

Translate

Translate

Report

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