Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • EspaƱol
      • FranƧais
      • PortuguĆŖs
  • ę—„ęœ¬čŖžć‚³ćƒŸćƒ„ćƒ‹ćƒ†ć‚£
  • ķ•œźµ­ ģ»¤ė®¤ė‹ˆķ‹°
0

Search for a inline object and a apply a paragraph style

Explorer ,
Oct 28, 2020 Oct 28, 2020

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
607
Translate
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

Translate
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

Translate
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
LATEST

Thank you! It works!

Nice to know about that parent.constructor thing!

Translate
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

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

Translate
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

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!

Translate
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