CreativePro Forum
Join our community of graphic designers, publishers, and production artists from around the world. Our members-only forum is a great place to discuss challenges and find solutions!
- You must be logged in to reply to this topic.Login
auto center object inline with height
- This topic has 13 replies, 2 voices, and was last updated 9 years, 7 months ago by
Anonymous.
-
AuthorPosts
-
-
May 13, 2016 at 10:05 pm #84892
Anonymous
Inactivehello, I’m new member of best website “indesignsecrets.com” and I have new at script. I want to have new script witch could be auto baseline align object in lines. you know, I have very object with different height. and those object are use in line with auto leading. but I want to align center those object with baseline like math object. can everyone help me?
-
May 14, 2016 at 8:00 pm #84898
Ari Singer
MemberCan you please post a screenshot of what you’re trying to achieve so we can better understand what you’re looking for?
You can post your screenshot on any cloud service (such as Google Drive or Dropbox) or any image-hosting site (such as imgur.com) and post the link here.
-
May 14, 2016 at 9:17 pm #84900
Anonymous
InactiveHello my friend. Thank you for your reply First. I uploaded at 4shared.com and you can see bellow link:
https://www.4shared.com/folder/jSGU0KvS/_online.html
-
-
May 14, 2016 at 9:24 pm #84901
Ari Singer
MemberCan you please upload it to Google Drive or Dropbox? 4Shared is too much of a hassle to download. Thanx!
-
May 14, 2016 at 9:37 pm #84902
Anonymous
InactiveYes of course.
https://www.dropbox.com/s/qx0h00dkmw3gutr/sample.rar?dl=0
Thanks
-
-
May 14, 2016 at 9:56 pm #84903
Ari Singer
MemberThanks. Now I understand what you mean. Will look into it to see if and how I can pull it off.
-
May 14, 2016 at 10:08 pm #84904
Anonymous
InactiveThank you very much. If you run this script, my problem with those object will be end. I’m work at text book. and that layout I sent you is normal for text book in my country.
Thanx
-
-
May 15, 2016 at 9:00 pm #84914
Ari Singer
MemberHere you go! i created this script, please let me know if it works.
To make it work you have to select a range of text (or a text frame) before running the script, and the script will adjust all the inline graphics in the selected text (or text frame).
If you don’t know how to use save and run this script, look here:https://creativepro.com/how-to-install-a-script-in-indesign-that-you-found-in-a-forum-or-blog-post.phpFolowing is the script:
//created by Ari S. designerjoe@outlook.com
// Automatically vertically center inline graphics
app.scriptPreferences.enableRedraw = false;
app.doScript(main, ScriptLanguage.JAVASCRIPT, undefined, UndoModes.ENTIRE_SCRIPT, "Adjust Inline Graphics Baseline");
function main() {
var myDoc = app.activeDocument;
with (myDoc.viewPreferences){
var myOldXUnits = horizontalMeasurementUnits;
var myOldYUnits = verticalMeasurementUnits;
horizontalMeasurementUnits = MeasurementUnits.points;
verticalMeasurementUnits = MeasurementUnits.points;
}
var mySelection = app.selection[0];
if (app.selection.length == 1){
//Evaluate the selection based on its type.
switch (app.selection[0].constructor.name){
case "InsertionPoint":
case "Character":
case "Word":
case "TextStyleRange":
case "Line":
case "Paragraph":
case "TextColumn":
case "Text":
case "Story":
//The object is a text object; pass it on to a function.
myAdjustBaseline(app.selection[0]);
break;
case "TextFrame":
myAdjustBaseline(app.selection[0].texts.item(0));
break;
default:
alert("The selected object is not a text object. Select some text and try again.");
break;
}
}
function myAdjustBaseline(text){
app.findChangeGrepOptions.includeLockedLayersForFind = false;
app.findChangeGrepOptions.includeLockedStoriesForFind = false;
app.findChangeGrepOptions.includeHiddenLayers = false;
app.findChangeGrepOptions.includeMasterPages = false;
app.findChangeGrepOptions.includeFootnotes = true;
app.findGrepPreferences = app.changeGrepPreferences = null;
app.findGrepPreferences.findWhat = "~a";
var myFound = text.findGrep(true);
for (i=0; i < myFound.length; i++){
var myGraphicPosition = myFound[i];
var myPointSize = myGraphicPosition.pointSize;
var myBounds = myGraphicPosition.texts[0].pageItems[0].geometricBounds;
var myHeight = myBounds[2] - myBounds[0];
if (myHeight >= myPointSize)
myGraphicPosition.baselineShift = -(myHeight/3);
else if (myHeight >= (0.75 * myPointSize))
myGraphicPosition.baselineShift = -(myHeight/4);
else if (myHeight >= (.6 * myPointSize))
myGraphicPosition.baselineShift = -(myHeight/5)
else if (myHeight <= (0.25 * myPointSize))
myGraphicPosition.baselineShift = (myHeight/4);
}
app.findGrepPreferences = app.changeGrepPreferences = null;
}
with (myDoc.viewPreferences){
try{
horizontalMeasurementUnits = myOldXUnits;
verticalMeasurementUnits = myOldYUnits;
}
catch(myError){
alert("Could not reset custom measurement units.");
}
}
}
-
May 15, 2016 at 10:08 pm #84915
Anonymous
Inactivewooooooow! Thanks alot. very very good, it is working without any problem!
-
May 15, 2016 at 10:30 pm #84916
Anonymous
InactiveMy friend. I check it again in my files, There is one problem, I have math object with eps format in my text. This script should be take all of objects without math object. Is there any chance?! but If it is not to do, no problem. by the way, your script work nice, and I can do with selection.
-
-
May 16, 2016 at 1:44 am #84919
Ari Singer
MemberI can only make the script omit the math object if it’s a different format than all other inline graphics. Is it? Or if all the math objects are the same size then I can try to make sure that all inline graphics of that size should not be touched.
-
May 16, 2016 at 3:34 am #84926
Anonymous
InactiveThank you for your attention and time
I got my request on the following link:
https://www.dropbox.com/s/sctj64gji46tzzq/sample2.rar?dl=0Thanks
-
-
May 16, 2016 at 3:53 am #84930
Ari Singer
MemberThanks. What I can do is tell the script that whenever it finds an EPS it should ignore it and not apply baseline shift. But this means that if you have more EPS’ in the file and you do want to adjust them it won’t work on that, because it will ignore any EPS.
Here’s the modified script that ignores any EPS:
//created by Ari S. designerjoe@outlook.com // Automatically vertically center inline graphics app.scriptPreferences.enableRedraw = false; app.doScript(main, ScriptLanguage.JAVASCRIPT, undefined, UndoModes.ENTIRE_SCRIPT, "Adjust Inline Graphics Baseline"); function main() { var myDoc = app.activeDocument; with (myDoc.viewPreferences){ var myOldXUnits = horizontalMeasurementUnits; var myOldYUnits = verticalMeasurementUnits; horizontalMeasurementUnits = MeasurementUnits.points; verticalMeasurementUnits = MeasurementUnits.points; } var mySelection = app.selection[0]; if (app.selection.length == 1){ //Evaluate the selection based on its type. switch (app.selection[0].constructor.name){ case "InsertionPoint": case "Character": case "Word": case "TextStyleRange": case "Line": case "Paragraph": case "TextColumn": case "Text": case "Story": //The object is a text object; pass it on to a function. myAdjustBaseline(app.selection[0]); break; case "TextFrame": myAdjustBaseline(app.selection[0].texts.item(0)); break; default: alert("The selected object is not a text object. Select some text and try again."); break; } } function myAdjustBaseline(text){ app.findChangeGrepOptions.includeLockedLayersForFind = false; app.findChangeGrepOptions.includeLockedStoriesForFind = false; app.findChangeGrepOptions.includeHiddenLayers = false; app.findChangeGrepOptions.includeMasterPages = false; app.findChangeGrepOptions.includeFootnotes = true; app.findGrepPreferences = app.changeGrepPreferences = null; app.findGrepPreferences.findWhat = "~a"; var myFound = text.findGrep(true); for (i=0; i < myFound.length; i++){ var myGraphicPosition = myFound[i]; if (myGraphicPosition.texts[0].pageItems[0].allGraphics[0].constructor.name == "EPS") continue; var myPointSize = myGraphicPosition.pointSize; var myBounds = myGraphicPosition.texts[0].pageItems[0].geometricBounds; var myHeight = myBounds[2] - myBounds[0]; if (myHeight >= myPointSize) myGraphicPosition.baselineShift = -(myHeight/3); else if (myHeight >= (0.75 * myPointSize)) myGraphicPosition.baselineShift = -(myHeight/4); else if (myHeight >= (.6 * myPointSize)) myGraphicPosition.baselineShift = -(myHeight/5) else if (myHeight <= (0.25 * myPointSize)) myGraphicPosition.baselineShift = (myHeight/4); } app.findGrepPreferences = app.changeGrepPreferences = null; } with (myDoc.viewPreferences){ try{ horizontalMeasurementUnits = myOldXUnits; verticalMeasurementUnits = myOldYUnits; } catch(myError){ alert("Could not reset custom measurement units."); } } }-
May 16, 2016 at 4:23 am #84933
Anonymous
InactiveIt’s perfect, I found this script for psd image, That well it works. thank you.
-
-
-
AuthorPosts
- The forum ‘General InDesign Topics (CLOSED)’ is closed to new topics and replies.
