Copy link to clipboard
Copied
Hi
I've have hundreds of documents to which I need to make a basic find/change to 15 identical items - find picture boxes and change a .5pt rounded corner, and a 1pt rounded corner to 0pt.
I'm used to using auto find change options to text, but I can't find any reference to changing the properties of an object with a script - can anyone point me in the right direction please?
Ideally I would like to add/run the script during a 'book' batch update script.
MTIA (anticipation)
Steve
1 Correct answer
Hi Steve,
You could use the object find option for your case. Try the following code to find the rectangles with .5pt rounded corners and change the corners to 0pt
...with(app.findObjectPreferences)
{
topLeftCornerOption = CornerOptions.ROUNDED_CORNER
topRightCornerOption = CornerOptions.ROUNDED_CORNER
bottomLeftCornerOption = CornerOptions.ROUNDED_CORNER
bottomRightCornerOption = CornerOptions.ROUNDED_CORNER
bottomLeftCornerRadius = ".5pt"
bottomRightCornerRadius = ".5pt"
Copy link to clipboard
Copied
Hi Steve,
You could use the object find option for your case. Try the following code to find the rectangles with .5pt rounded corners and change the corners to 0pt
with(app.findObjectPreferences)
{
topLeftCornerOption = CornerOptions.ROUNDED_CORNER
topRightCornerOption = CornerOptions.ROUNDED_CORNER
bottomLeftCornerOption = CornerOptions.ROUNDED_CORNER
bottomRightCornerOption = CornerOptions.ROUNDED_CORNER
bottomLeftCornerRadius = ".5pt"
bottomRightCornerRadius = ".5pt"
topLeftCornerRadius = ".5pt"
topRightCornerRadius = ".5pt"
}
with(app.changeObjectPreferences)
{
bottomLeftCornerRadius = "0pt"
bottomRightCornerRadius = "0pt"
topLeftCornerRadius = "0pt"
topRightCornerRadius = "0pt"
}
app.documents[0].changeObject()
app.findObjectPreferences = NothingEnum.nothing
app.changeObjectPreferences = NothingEnum.nothing
-Manan
Copy link to clipboard
Copied
Hi Manan
thanks for the suggestion, but when I run the script with the document open I get an error.
I don't have enough knowledge to try to find out why.
Regards, Steve
Copy link to clipboard
Copied
Hi,
Its Indesign javascript. so, please use InDesign ExtendScript Toolkit.
Thanks,
Prabu
Prabu
Design smarter, faster, and bolder with InDesign scripting.
Copy link to clipboard
Copied
Hi Prabu
Sorry to be a pain!
I'm running InDesign CC 13.1
the first thing I did was save your text as a file with .jsx extension and put it in the scripts folder. But when I clicked it nothing happened. Which is why I mistakenly tried saving it as an Applescript file.
I have never before used ExtendScriptToolkit. I launched it and pasted your text into the UI but the dropdown list doesn't feature InDesign, and when I run as ExtendScript Toolkit CC it errors with 'Cannot execute script in target engine 'main''
Copy link to clipboard
Copied
Hi Steve,
if you want to run the script from the ESTK, first start InDesign.
The ESTK should be able to identify InDesign CC 2018.1 as target.
Unfortunately this seems not to be the case in your system.
You also said you executed a jsx file with Manan's code from InDesign's Scripts panel.
Nothing happened? No error message?
So it could be that no object was found that fits the criteria of the findObjectPreferences in the code.
Note: All properties that are not declared in the code will be taken from the defaults of your InDesign version.
So perhaps all the objects you want to change are on locked layers?
Regards,
Uwe
Copy link to clipboard
Copied
Hi Steve,
Can you send us a sample document, i will tweak the code as per the requirements and let you know what is the cause of no result or error at your end. You can share the document using Dropbox, Google Drive(make sure the link is public to all) or any other such service.
-Manan
Copy link to clipboard
Copied
Copy link to clipboard
Copied
Hi Steve,
I checked your document and i see that the objects that you were showing don't have corner as 1 picas as you have set in your code, see the screenshot of your document with the corner options dialog open for one of the object selected.
However i also noticed that if the unit is in decimals and not a whole number the Find/Change is not able to find the objects sometimes. As is happening in your case even if you use correct values, neither the code nor the Find/Change dialog works for me. For whole numbers it seems to work. One workaround might be that you apply an object styles on these objects and try to find that.
Laubender​ can you verify if using decimal numbers works reliably for you or not. I tested on MAC CC2017.
-Manan
Copy link to clipboard
Copied
Hi Manan
I'm very sorry - I didn't originate these documents (I'm old school and use points for type & strokes).
The corner option settings are in mm - 0.5mm!
I have changed the units in your script from "p" to "mm" and it works perfectly!
Sorry to have been the cause of an unnecessary issue?
Many thanks, Steve.
Copy link to clipboard
Copied
Hi Prabu
Thanks for your patience.
Minor progress for me but still not working!
Once I right-clicked your script (InDesign Script UI) to edit, it launched the correct ExtendScript Toolkit version and I was able to select my version of InDesign from the dropdown list - but it still returns the error when run 'Cannot execute script in target engine 'main'.
If I double click the script in the 'InDesign Script window' nothing happens.
Items are on a layer called 'icons' but it is not locked.
Regards, Steve
Copy link to clipboard
Copied
Steve,
Are you able to search for these objects by using the Find/Change dialog? And also if possible share a sample document
-Manan
Copy link to clipboard
Copied
Hi Manan
yes I have saved an 'object' search that will find and replace all 0.5pt round corners to 0pt corners.
( I also made one for 1.0pt round corners to 0pt corners as I found another instance)
These work well but what I wanted to do was reduce the work time on this change.
I have multiple book files containing six or seven book files each. The files contain multiple 'live' Excel spreadsheet data.
When the 'book file' is open on the desktop I use a 'Batch processor' script written by Kasyan Servetsky (http://www.kasyan.ho.com.ua). This script opens all the book files and allows you to pick scripts to run on these files when they open. I use one script to update all links. I would like to run another script (the one you have been helping me with) to change all round cornered boxes (both 0.5pt & 1.0pt) to 0pt corners.
Regards, Steve
Copy link to clipboard
Copied
Hi Steve,
Manan's script is no AppleScript, it's language is ExtendScript.
To save ExtendScript code, install the script and execute it see:
Indiscripts :: Indiscripts for Dummies
Regards,
Uwe
Copy link to clipboard
Copied
Hi Steve,
instead of Manan's script you could also work with Object Find/Change in InDesign's UI.
From my German InDesign CC 2019 where I am looking for All Frames ( you could fine tune this ) with rounded corners where the radius is 0.5 Pt. Change that to not rounded corners with radius 0. Do that for all open documents.
Regards,
Uwe
Copy link to clipboard
Copied
Hi Uwe
that was my first point of call - I was then hoping to save the search as a text file and run it through the find/change script, as I have done with multiple text & GREP find change items. Being an 'object' change it didn't seem to work.
I have some options above that I'm in the process of trying to understand/implement.
Many thanks
Steve
Copy link to clipboard
Copied
Hi Steve,
just looked into FindChangeList.txt file.
The comments at the start of the document say:
…
//findType is "text", "grep", or "glyph" (this sets the type of find/change operation to use).
…
So, unfortunately, no support for findType "object".
Regards,
Uwe
Copy link to clipboard
Copied
FindChangeByList.jsx reads
...
case "glyph":
myFindGlyph(myObject, myFindPreferences, myChangePreferences, myFindChangeOptions);
break;
and you can add a further
case "object":
myFindObject(myObject, myFindPreferences, myChangePreferences, myFindChangeOptions);
break;
beneath it, and lower on, copy the myFindGlyph function and change all occurrences of "Glyph" into "Object". From a quick glance, that should be totally do-able.
This will work because basically all the script does is it literally copies the find/change strings from the external file "into" the script itself. So all you have to do is find out what these correct properties are. I suppose Grefel's can help here: https://www.indesignjs.de/extendscriptAPI/indesign-latest/#FindChangeObjectOption.html for the options, and https://www.indesignjs.de/extendscriptAPI/indesign-latest/#FindObjectPreference.html and https://www.indesignjs.de/extendscriptAPI/indesign-latest/#ChangeObjectPreference.html for the actual properties.
Copy link to clipboard
Copied
Correct answer, with the proviso that I gave Manan the incorrect measurement to work with!
For me the dimension should have been 'mm' not 'p'
Many thanks, Steve

