Forum Replies Created
-
AuthorPosts
-
Jeremy Howard
ParticipantHere is that same script without the comments on every line (just in case you find it less confusing).
(*======================== BEGIN SCRIPT ==============================*)
tell application id “com.adobe.indesign”
repeat 1 timesif (count of documents) = 0 then
display dialog “Please open a document and try again.”
exit repeat
end ifset myDoc to active document
set myPageItems to every page item of myDoc
set imageFrameArray to {}tell myDoc to ungroup every group
try
set myDestLayer to layer “Images” of myDoc
on error
tell myDoc to set myDestLayer to make layer with properties {name:”Images”}
end tryrepeat with i from 1 to length of myPageItems
set aFrame to item i of myPageItemsif class of aFrame = group then
set myGroupFrames to every page item of aFrame
repeat with g from 1 to length of myGroupFrames
set gFrame to item g of myGroupFramesif class of gFrame = rectangle or class of gFrame = polygon or class of gFrame = oval then
copy gFrame to the end of imageFrameArray
end if
end repeat
else if class of aFrame = rectangle or class of aFrame = polygon or class of aFrame = oval then
copy aFrame to the end of imageFrameArray
end if
end repeatrepeat with x from 1 to length of imageFrameArray
set thisFrame to item x of imageFrameArraytry
set myLinkedItem to page item 1 of thisFrame
set myLinkName to name of item link of myLinkedItem
set item layer of thisFrame to myDestLayer
end tryend repeat
display dialog “Finished.”
end repeat
end tell
(*======================== END SCRIPT ==============================*)Jeremy Howard
ParticipantYou can do it using the same method that you would if were a rectangle:
myOvalTextFrame.geometricBounds
Jeremy Howard
ParticipantHello Silvio,
I’m glad to hear that you are getting into scripting! Instead of telling you how to run the ExtendScript that I wrote from AppleScript, I opted to write an AppleScript version. I added a comment to each line that explains how each line corresponds to the javascript that I posted before.
I hope this helps. Enjoy!
(*======================== BEGIN SCRIPT ==============================*)
tell application id “com.adobe.indesign” –Defining the application this way makes it “version proof” it will attempt to use the newest version of InDesign
repeat 1 times –Set to repeat once. This means that the script will only run through once but it allows us to use the “exit repeat” command to exit the scriptif (count of documents) = 0 then –this if statement is the same as: if (app.documents.length == 0) ErrorExit(“Please open a document and try again.”, true);
display dialog “Please open a document and try again.”
exit repeat –Exits the repeat 1 times statement
end ifset myDoc to active document –SAME AS: var myDoc = app.activeDocument;
set myPageItems to every page item of myDoc –SAME AS: var myPageItems = app.activeDocument.allPageItems;
set imageFrameArray to {} –SAME AS: var imageFrameArray = new Array();tell myDoc to ungroup every group — I had to add this because of the way that AppleScript interacts with the frames within a group
try –SAME AS: try{
set myDestLayer to layer “Images” of myDoc –SAME AS: var myDestLayer = myDoc.layers.add({name:”Images”});
on error –SAME AS: }catch(foo){
tell myDoc to set myDestLayer to make layer with properties {name:”Images”} –SAME AS: myDestLayer = myDoc.layers.item(“Images”);
end try –SAME AS: }repeat with i from 1 to length of myPageItems –SAME AS: for(var i = 0; i < myPageItems.length; i++){
set aFrame to item i of myPageItems –SAME AS: var aFrame = myPageItems[i];if class of aFrame = group then –SAME AS: if(aFrame == “[object Group]”){
set myGroupFrames to every page item of aFrame –SAME AS: var myGroupFrames = aFrame.allPageItems;
repeat with g from 1 to length of myGroupFrames –SAME AS: for(g = 0; g < myGroupFrames.length; g++){
set gFrame to item g of myGroupFrames –SAME AS: var gFrame = myGroupFrames[g];
–if the current frame is an image frame
if class of gFrame = rectangle or class of gFrame = polygon or class of gFrame = oval then –SAME AS: if(gFrame instanceof Rectangle || gFrame instanceof Polygon || gFrame instanceof Oval){
copy gFrame to the end of imageFrameArray –SAME AS: imageFrameArray.push(gFrame);
end if –SAME AS: }
end repeat — end repeat with g from 1 to length of myGroupFrames
else if class of aFrame = rectangle or class of aFrame = polygon or class of aFrame = oval then –SAME AS: }else if(aFrame instanceof Rectangle || aFrame instanceof Polygon || aFrame instanceof Oval){
copy aFrame to the end of imageFrameArray –SAME AS: imageFrameArray.push(aFrame);
end if –SAME AS: }
end repeat –SAME AS: }repeat with x from 1 to length of imageFrameArray –SAME AS: for(x=0; x<imageFrameArray.length;x++){
set thisFrame to item x of imageFrameArray –SAME AS: var thisFrame = imageFrameArray[x];try –SAME AS: try{
set myLinkedItem to page item 1 of thisFrame –SAME AS: var myLinkedItem = thisFrame.pageItems[0];
set myLinkName to name of item link of myLinkedItem –SAME AS: var myLinkName = myLinkedItem.itemLink.name;
set item layer of thisFrame to myDestLayer –SAME AS: thisFrame.itemLayer = “Images”;
end try –SAME AS: }end repeat –SAME AS: }
display dialog “Finished.” –SAME AS: alert(“Finished.”, scriptName);
end repeat –End of the “repeat 1 times” statement
end tell(*======================== END SCRIPT ==============================*)
December 12, 2019 at 5:04 am in reply to: GREP Expression – formatting names at the beginning of a paragraph #14323577Jeremy Howard
ParticipantIt’s true that nested styles are easier to implement but I am a bit of a GREP wonk so that’s the way I usually go with these things.
Try this expression on for size:
^u\w+(\u)?\u\w+
If it works as expected then I’ll drop back in later and explain the expression for you (I have to get my son on the bus now :))
December 9, 2019 at 11:40 pm in reply to: Re-arranging Pages Panel to Imposition in Indesign #14323603Jeremy Howard
Participant+1 to Dieter’s comment.
If you create your design across the entire spread and export the PDF as a spread then you won’t be left with the gaps in the middle.
Disclaimer: I am speaking from my experience in the comp department at a printing press. I am making the assumption that this approach will work for your digital printing process but I don’t really know =)
Jeremy Howard
ParticipantUpdate – Issue Has Been Resolved!
I finally found the solution I was looking for after a whole bunch of digging around and reading. Here is what I figured out:
——————————————————————————————————–——————————————————————————————————–——————————————————————————————————–
var aDialog = new Window(‘dialog’, “Dialog Title”,);
aDialog.orientation: ‘column’
aDialog.preferredSize: [300,100]
aDialog.add(‘statictext’, undefined, “Some dialog contents here.”);var myButtonGroup = aDialog.add(‘group’);
var cancelButton = myButtonGroup.add(‘button’, undefined, “Cancel”,{name: “Cancel”});
var proceedButton = myButtonGroup.add (‘button’, undefined, “Continue”,{name: “proceedButton”});proceedButton.onClick = function(){
aDialog.close(1)
}var dialogResult = aDialog.show()
if(dialogResult == 1){
app.doScript(mainFunction, ScriptLanguage.JAVASCRIPT, undefined, UndoModes.ENTIRE_SCRIPT, “Undo Name”);
}else if (dialogResult== 2){
alert(“You clicked the Cancel button!”);
exit(0);
}function mainFunction(){
app.selection = app.activeDocument.pageItems[0];
}
——————————————————————————————————–——————————————————————————————————–——————————————————————————————————–This works as i was hoping and will run the function without that pesky error!
Jeremy Howard
ParticipantHello Brett, I’m not sure if you saw my response to your previous post on this topic. I posted a solution there that involved using soft returns to separate your lines instead of using paragraph returns.
Using that solution would allow you to use a nested GREP style and you wouldn’t need to run a find/change or a script of any kind. The styling would happen automatically! :)
Jeremy Howard
ParticipantAh, try to show your frame edges…
Shift+command+h (mac)
Shift+control+h (windows)Or, buried in view>extras or something…
Jeremy Howard
ParticipantThe “x” is representation of the type of frame that you have in your document. There are 3 different types of frames in InDesign, all of which are defined by their content (or intended content). The three frame types are Text, Graphic and Unassigned.
The issue that you’re having has to do with the content setting on the frames in your document, they are probably currently set to either “Text” or “Unassigned”. To get the “x” back on these frames, you’ll need to adjust the content setting for them.
Select the frame(s) that you would like to adjust, go to Object>Content>Graphic and… presto! Your “x” placeholder is back!
Jeremy Howard
ParticipantJeremy Howard
ParticipantHey Charles,
To solve your problem, we will need to employ a method that was used in the dark days before paragraph shading; underline options.
First, create a paragraph style that you will be using on your text. Let’s call this paragraph style “Main Para Style”. For my example, my “Main Paragraph Style” is going to be 20pt text.
Next, create a new character style and name it something super cool (a cool name is an absolute must for this to work). Go to “Underline Options” in your super cool new character style and make sure that you have the “Underline On” box checked. It is also helpful to make sure that you have the “Preview” box checked as well (so that you can see what you’re doing).
Make the underline weight a point or two more than your paragraph style’s text size. In my example, my “Main Para Style” is 20pt text so I am going to make the underline weight 22pt. Now you will need to adjust the “Offset” of the underline to bring it up behind the text. The offset in my example style is -6.
Finally, go to your paragraph style and under the “Drop Caps and Nested Styles” options, add a new nested style that applies your super cool character style through 1 letter.
That’s it! You now have a super cool paragraph style that has block shading behind the first letter!
November 18, 2019 at 8:38 am in reply to: Text Frame Top and Bottom Margins Changing When Pasting Between Documents #14323687Jeremy Howard
ParticipantThe easiest thing to do is:
• Select the frame (which will select the “[None]” style in your Object Styles panel.
• Click the “Create New Style” button. This will create a new style whose definition contains the overrides that are on the “[None]” style.
• Enter a name for the styleNow when you copy and paste the text frame, the new Object Style will come into the document along with the frame.
Jeremy Howard
ParticipantThis may be what you are looking for:
\$\d+?\.\d+?\K(o|t|f)(\w+)?
I just added “(\w+)?” to the end of the GREP expression that Aaron Troia posted.
The Breakdown:
“\w” = any word character
“+” = one or more times
“(” & “)” = enclosing an expression the create a “captured group”
“?” = may or may not exist.Jeremy Howard
ParticipantLocky, I believe that this is what you are looking for:
//—–BEGIN SCRIPT—–//
for(var x=0;x<app.documents.length;x++){
var currentDoc = app.documents[x];
var linksIDs = currentDoc.links.everyItem().id;
for(var n=0;n<linksIDs.length;n++){
try{
currentDoc.links.itemByID(linksIDs[n]).parent.parent.images[0].clippingPath.clippingType = ClippingPathType.PHOTOSHOP_PATH;
currentDoc.links.itemByID(linksIDs[n]).parent.parent.images[0].clippingPath.convertToFrame();
}catch(e){};
};
};//—–END SCRIPT—–//
The main thing to focus on here is the addition of this line:
currentDoc.links.itemByID(linksIDs[n]).parent.parent.images[0].clippingPath.convertToFrame();November 8, 2019 at 7:19 am in reply to: Script to Replace Existing Paragraph Styles With New Style #14323778Jeremy Howard
ParticipantThis can also be easily accomplished by using the Find Font dialog (found under Type>Find Font).
Once you have that dialog open, simply select the font that you want to replace, specify the replacement font and make sure you have the “Redefine Styles” option ticked on. Click “Replace” and all of your style sheets will be updated.
No need for scripts on this one!
-
AuthorPosts
