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

Search for a inline object and a apply a paragraph style

Explorer ,
Oct 28, 2020 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.

TOPICS
Scripting

Views

365

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

Community Expert , Oct 28, 2020 Oct 28, 2020

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

Votes

Translate

Translate
Community Expert ,
Oct 28, 2020 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

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 ,
Oct 29, 2020 Oct 29, 2020

Copy link to clipboard

Copied

LATEST

Thank you! It works!

Nice to know about that parent.constructor thing!

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
Guide ,
Oct 29, 2020 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

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 ,
Oct 29, 2020 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!

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