Sunday, December 15, 2019

#1 2019-07-15 03:48:43 am

eaglen
Member
Registered: 2008-05-13
Posts: 17

InDesign unable to apply object syle to labelled text boxes

Good morning,

I wonder if somebody could pleases assist me, either by assisting with the code or telling me it cannot be done.

We have 4 catalogues each with 1,000 stock items which need to be updated monthly or whenever we add new products to our ranges and I have been reasonably successful in building a script that can do this with a fairly basic layout. To improve the appearance I wanted to add 3 varying object styles to each  product listing, drop shadow and rounded border. After adding the object style I need to use the the "fit given frame to content" command to shrink borders to the text descriptions. The shrink to bit works fine.

Applescript:


tell application "Adobe InDesign CC 2019"
   tell myDoc
       tell (every text frame whose label is "shadStyle")
           -->> This is where I want to put the "set object style: command <<--
           fit given frame to content
       end tell
   end tell
end tell

I also tried a bit of the code from StefanK posted back in 2006 hoping it'd point me in the right direction, and for a moment as all the text boxes shrunk I was ecstatic! I substituted the geometric bounds bit for applied object style:object style catLeft that I have used previously making text boxes...

Applescript:


tell application "Adobe InDesign CC 2019"
       tell myDoc
           repeat with oneFrame in (get text frames whose label is "shadStyle")                
               set {a, b, c, d} to geometric bounds of oneFrame
               set geometric bounds of oneFrame to {a, b, c, 25}
-->> This is where I want to put the "set object style: command <<--
           end repeat
       end tell
   end tell

...but this didn't work either!

Thank you in anticipation of somebody being able to point me in the right direction.

Martin

Model: late 2013 Mac Pro
AppleScript: 2.7
Browser: Firefox 68.0
Operating System: macOS 10.14

Last edited by eaglen (2019-07-15 03:50:30 am)

Offline

 

#2 2019-07-15 12:51:30 pm

KniazidisR
Member
Registered: 2019-03-03
Posts: 802

Re: InDesign unable to apply object syle to labelled text boxes

For your task use this:

Applescript:


tell application "Adobe InDesign CC 2019"
   set myDoc to document 1
   
   tell myDoc
       set theTextFrames to text frames
       repeat with i from 1 to count of theTextFrames
           set theFrame to item i of theTextFrames
           if label of theFrame is "shadStyle" then
               -->> HERE put the "set object style: command <<--
           end if
       end repeat
   end tell
   
end tell

Better solution:

Applescript:


tell application "Adobe InDesign CC 2019"
   set myDoc to document 1
   tell myDoc
       set theTextFrames to every text frame of every spread whose label is "ShadStyle"
       repeat with i from 1 to count of theTextFrames
           set theFrame to item i of theTextFrames
           -->> HERE put the "set object style: command <<--
       end repeat
   end tell
end tell

NOTE: Your mistake is telling in whose clause to Document directly, and you should tell first to Spreads. Usefull clause whose always requires full path

Last edited by KniazidisR (2019-07-15 01:41:50 pm)


Model: MacBook Pro
macOS Mojave -- version 10.14.4
Safari -- version 12.1
Firefox -- version 70.0

Offline

 

#3 2019-07-17 01:24:30 am

eaglen
Member
Registered: 2008-05-13
Posts: 17

Re: InDesign unable to apply object syle to labelled text boxes

Good morning Kniazidis,

Thank you for your reply and solution, not only for this particular problem, but for helping me understand the method on which I structure commands and where to address them.

I am on my way to the studio and eager to try this out and I'll drop you a message later this morning to let you know how I get on.

Meanwhile, kindest regards
Martin

Offline

 

#4 2019-07-17 02:54:26 am

eaglen
Member
Registered: 2008-05-13
Posts: 17

Re: InDesign unable to apply object syle to labelled text boxes

Good morning Kniazidis,

I can't thank you enough for your help. We'll now have catalogues that looks good a well as being functional.

Here's the complete code that I used with the object style in place.

Applescript:


tell application "Adobe InDesign CC 2019"
   set myDoc to document 1
   tell myDoc
       set theTextFrames to every text frame of every spread whose label is "ShadStyle"
       repeat with i from 1 to count of theTextFrames
           set theFrame to item i of theTextFrames
           -->> below is where I put the set object style command <<--
           set myObjectStyle to object style "catRight" of myDoc
           tell theFrame to apply object style using myObjectStyle clearing overrides yes
       ----------------------^^^^^^^^^^^^^^^^^^^^^^^----------------------
       end repeat
   end tell
end tell

Thank you once again.

Kindest regards
Martin

Offline

 

#5 2019-07-17 03:09:40 am

KniazidisR
Member
Registered: 2019-03-03
Posts: 802

Re: InDesign unable to apply object syle to labelled text boxes

You are welcome. I’ll say one last thing: the code line set myDoc to document 1 can be removed, and you can directly tell to document 1 (I inserted this line for demonstrative purposes only, for you), if you don’t use the variable myDoc elsewhere in the larger script:

Applescript:


tell application "Adobe InDesign CC 2019"
   tell document 1
       set theTextFrames to every text frame of every spread whose label is "ShadStyle"
       repeat with i from 1 to count of theTextFrames
           set theFrame to item i of theTextFrames
           -->> below is where I put the set object style command <<--
           set myObjectStyle to object style "catRight"
           tell theFrame to apply object style using myObjectStyle clearing overrides yes
           ----------------------^^^^^^^^^^^^^^^^^^^^^^^----------------------
       end repeat
   end tell
end tell

Last edited by KniazidisR (2019-07-18 12:35:13 am)


Model: MacBook Pro
macOS Mojave -- version 10.14.4
Safari -- version 12.1
Firefox -- version 70.0

Offline

 

#6 2019-07-17 09:46:08 am

eaglen
Member
Registered: 2008-05-13
Posts: 17

Re: InDesign unable to apply object syle to labelled text boxes

Hi Kniazidis,

Thank you for your follow up and additional information. With your help I've managed to navigate around the order in which I need to call on the variables and send the commands.

Now I think my biggest problem is going to be just how to limit the complexity of the final design and to avoid just doing things because I can! big_smile

Kindest regards
Martin

Offline

 

Board footer

Powered by FluxBB

RSS (new topics) RSS (active topics)