Highlighted

Search for a inline object and a apply a paragraph style

Community Beginner ,
Oct 28, 2020

Copy link to clipboard

Copied

Hi!

I need to find all inline elements with a object style applied on it go to the paragraph where they are placed and apply a different paragraph style. See the images for examples.

 

Here the object style applied:

image1.jpg

 

I want to find them, go to their paragraph:

image2.jpg

 

And apply other paragraph style (one with spaces before and after):

image3.jpg

 

Is this possible with a script? I'm sending the indesign files too!
Please help me.

Adobe Community Professional
Correct answer by Manan Joshi | Adobe Community Professional

Hi @Thiago Ribeiro Nogueira,

Try the following code

app.findObjectPreferences.appliedObjectStyles = "box"
var r = app.activeDocument.findObject()
for(var i = 0; i < r.length; i++)
{
	if(r[i].parent.constructor.name == "Character")
		r[i].parent.appliedParagraphStyle = "space"
}
app.findObjectPreferences.appliedObjectStyles = null

-Manan

TOPICS
Scripting

Views

56

Likes

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

Search for a inline object and a apply a paragraph style

Community Beginner ,
Oct 28, 2020

Copy link to clipboard

Copied

Hi!

I need to find all inline elements with a object style applied on it go to the paragraph where they are placed and apply a different paragraph style. See the images for examples.

 

Here the object style applied:

image1.jpg

 

I want to find them, go to their paragraph:

image2.jpg

 

And apply other paragraph style (one with spaces before and after):

image3.jpg

 

Is this possible with a script? I'm sending the indesign files too!
Please help me.

Adobe Community Professional
Correct answer by Manan Joshi | Adobe Community Professional

Hi @Thiago Ribeiro Nogueira,

Try the following code

app.findObjectPreferences.appliedObjectStyles = "box"
var r = app.activeDocument.findObject()
for(var i = 0; i < r.length; i++)
{
	if(r[i].parent.constructor.name == "Character")
		r[i].parent.appliedParagraphStyle = "space"
}
app.findObjectPreferences.appliedObjectStyles = null

-Manan

TOPICS
Scripting

Views

57

Likes

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
Oct 28, 2020 0
Adobe Community Professional ,
Oct 28, 2020

Copy link to clipboard

Copied

Hi @Thiago Ribeiro Nogueira,

Try the following code

app.findObjectPreferences.appliedObjectStyles = "box"
var r = app.activeDocument.findObject()
for(var i = 0; i < r.length; i++)
{
	if(r[i].parent.constructor.name == "Character")
		r[i].parent.appliedParagraphStyle = "space"
}
app.findObjectPreferences.appliedObjectStyles = null

-Manan

Likes

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
Reply
Loading...
Oct 28, 2020 2
Community Beginner ,
Oct 29, 2020

Copy link to clipboard

Copied

Thank you! It works!

Nice to know about that parent.constructor thing!

Likes

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
Reply
Loading...
Oct 29, 2020 0
Adobe Community Professional ,
Oct 29, 2020

Copy link to clipboard

Copied

Instead the box you could do a paragraph style as in my example below. Than you can easily find all these paragraphs and apply different paragraph styles.

ezgif.com-video-to-gif(1).gif

Likes

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
Reply
Loading...
Oct 29, 2020 3
Community Beginner ,
Oct 29, 2020

Copy link to clipboard

Copied

Hi vladan!

My file is only a example file. I really want to apply paragraph style to these inline objects, because this will make easy a export HTML thing that I'm work in. But thank you for your answer!

Likes

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
Reply
Loading...
Oct 29, 2020 0