Back

If your email is not recognized and you believe it should be, please contact us.

Forum Replies Created

Viewing 15 posts - 76 through 90 (of 92 total)
  • Author
    Posts
  • Vinny –
    Member

    Year1917…
    When “a few comments” happen to be a list of very specific requests, I guess it’s time to think about hiring a professional scripter.
    You can ask obiwan, I’m sure he’ll be glad to help.
    All the best

    Vinny –
    Member

    Salut Michel et… bonne année ! ^^
    Je te crois sur parole, mais je suis en plein apprentissage du scripting alors j’ai sûrement tendance à être très verbeux. N’hésite pas à partager tes deux lignes, ainsi après avoir été mon Maître es GREP, tu pourras aussi devenir mon Maître es Script ^^
    Quant à la possibilité de faire ça nativement, j’avoue je sèche. Utiliser Grep pour compter le nombre de caractères avant que ça “coupe” m’est bien venu à l’esprit, mais c’est évidemment très peu précis et donc à exclure. Un indice ?

    Vinny –
    Member

    This forum is a goldmine to get exercises for scripting ^^
    Try this script and tell me if it works for you:
    Please note:
    – select a text frame, or place the cursor in order to apply the script to the whole story
    – an existing character style called “bold” must exist. You can change the name on line 37 (var myCSName = “bold”;)
    – script will clear all paragraphs overrides in the selected story, so be cautious
    – if you don’t use the download link below and copy/paste your code, please replace opening/closing quotation marks by straight one.
    here’s the download link: https://wetransfer.com/downloads/2887b2f63a8f8b3b0fd0adad10e99e7f20180116105700/19df9614bd16a55c5faf1d7bcc0eef8120180116105700/e08e08

    and here’s the javascript:

    //Written by Vinny
    // Feel free to modify and use

    main();

    function main() {
    //Make certain that user interaction (display of dialogs, etc.) is turned on.
    app.scriptPreferences.userInteractionLevel = UserInteractionLevels.interactWithAll;
    if (app.documents.length != 0) {
    if (app.selection.length == 1) {
    switch (app.selection[0].constructor.name) {
    case “Text”:
    case “TextFrame”:
    case “InsertionPoint”:
    case “Character”:
    case “Word”:
    case “Line”:
    case “TextStyleRange”:
    case “Paragraph”:
    case “TextColumn”:
    CheckifCharStyleExists();
    break;
    default:
    alert(“The selected object is not a text object. Select some text and try again.”);
    break;
    }
    } else {
    alert(“Please select some text and try again.”);
    }
    } else {
    alert(“No documents are open. Please open a document, select some text, and try again.”);
    }

    function CheckifCharStyleExists() {
    var myDocument = app.documents.item(0);
    var myParagraphs = app.selection[0].parentStory.paragraphs;
    var myCSName = “bold”;
    var myCharacterStyle = myDocument.characterStyles.item(myCSName);

    if (myDocument.characterStyles.item(myCSName) == null) {
    alert(“\””+myCSName+”\” character style does not exist. Please create it.”);
    } else {
    AddNestedStyle();
    }

    function AddNestedStyle() {
    app.selection[0].parentStory.clearOverrides(OverrideType.PARAGRAPH_ONLY);

    for (i = 0; i < myParagraphs.length; i++) {
    if (myParagraphs[i].lines.length > 1) {
    var myNestedStyle = myParagraphs[i].nestedStyles.add({
    appliedCharacterStyle: myCharacterStyle,
    delimiter: NestedStyleDelimiters.ANY_WORD,
    inclusive: true,
    repetition: 2
    });
    }
    }
    }
    }
    }

    in reply to: Auto Size text boxes #100951
    Vinny –
    Member

    Hi Brenda.
    So if I understand well, you want to some of switch.
    A script that would turn ON autosizing if it’s OFF and that would turn it OFF it was ON. Am I correct?
    If that so, you can try the script below: (don’t forget to change quote marks to straight ones)
    main();

    function main() {
    //Make certain that user interaction (display of dialogs, etc.) is turned on.
    app.scriptPreferences.userInteractionLevel = UserInteractionLevels.interactWithAll;
    if (app.documents.length != 0) {
    if (app.selection.length == 1) {
    switch (app.selection[0].constructor.name) {
    case “TextFrame”:
    AutosizeOnOff();
    break;
    default:
    alert(“The selected object is not a text frame. Select some text and try again.”);
    break;
    }
    } else {
    alert(“Please select a single text frame and try again.”);
    }
    } else {
    alert(“No documents are open. Please open a document, select some text, and try again.”);
    }
    }

    function AutosizeOnOff() {
    var myDocument = app.activeDocument;
    var myObject = app.selection[0];

    if (myObject.textFramePreferences.autoSizingType == AutoSizingTypeEnum.OFF) {
    myObject.textFramePreferences.autoSizingReferencePoint = AutoSizingReferenceEnum.TOP_CENTER_POINT; //Change if necessary. See https://jongware.mit.edu/idcs6js/pe_AutoSizingReferenceEnum.html
    myObject.textFramePreferences.autoSizingType = AutoSizingTypeEnum.HEIGHT_ONLY; //Change if necessary. See https://jongware.mit.edu/idcs6js/pe_AutoSizingTypeEnum.html
    alert(“Autosizing is now ON”); // delete this line if you don’t want the alert box anymore
    } else {
    myObject.textFramePreferences.autoSizingType = AutoSizingTypeEnum.OFF;
    alert(“Autosizing is now OFF”); // delete this line if you don’t want the alert box anymore
    }
    }

    Download link below:
    https://wetransfer.com/downloads/74d0c2189052ea61ce08f345896008d420180115083705/1192836602fa365851f4880b5dc73a3020180115083705/21a89c

    Let me know if it works for you
    Vinny

    in reply to: Auto Size text boxes #100929
    Vinny –
    Member

    Sorry Brenda, it’s weekend time…
    Besides, what’s the point? Are you just trying to fit frame to content with a shortcut? If that so, you should be able to achieve it without scripting.
    Could you be more specific about what exactly you want to do?
    Also please note the provided script not only turn on autosizing, but also applied an object style.

    in reply to: Auto Size text boxes #100920
    Vinny –
    Member
    in reply to: Auto Size text boxes #100918
    Vinny –
    Member

    Oh and the last 3 lines should come before the preceding brace }
    Pity we can’t edit posts…

    in reply to: Auto Size text boxes #100917
    Vinny –
    Member

    Hmmm not too bad… Apparently only quote marks have been converted.
    In your code editor, just change them back (both opening and ending) to straight quotes and it should be OK.
    ^^

    in reply to: Auto Size text boxes #100916
    Vinny –
    Member

    Hi Brenda.
    I suppose this could be scripted. Then just apply a keyboard shortcut to the script.
    Here’s an example I just wrote (based on Adobe’s CreateCharacterStyle.jsx):
    Although I am very unsure how this WP forum handles codes and a bit worried it would remove some characters…

    main();
    function main(){
    //Make certain that user interaction (display of dialogs, etc.) is turned on.
    app.scriptPreferences.userInteractionLevel = UserInteractionLevels.interactWithAll;
    if (app.documents.length != 0){
    if (app.selection.length == 1){
    switch (app.selection[0].constructor.name){
    case “TextFrame”:
    myDefineObjectStyle();
    break;
    default:
    alert(“The selected object is not a text frame. Select some text and try again.”);
    break;
    }
    }
    else{
    alert(“Please select a single text frame and try again.”);
    }
    }
    else{
    alert(“No documents are open. Please open a document, select some text, and try again.”);
    }
    }

    function myDefineObjectStyle(myCharacterStyleName){
    var myDocument = app.activeDocument;
    var myObjectStyleName = “Auto-resize text frame height”;

    //Create the object style if it does not already exist.
    myObjectStyle = myDocument.objectStyles.item(myObjectStyleName);
    try{
    myObjectStyle.name;
    }
    catch (myError){
    myObjectStyle = myDocument.objectStyles.add({name:myObjectStyleName});
    }

    //Object Syle settings
    myObjectStyle.basedOn = myDocument.objectStyles[0];
    myObjectStyle.enableTextFrameAutoSizingOptions = true;
    myObjectStyle.textFramePreferences.autoSizingType = AutoSizingTypeEnum.HEIGHT_ONLY; //Change if necessary
    myObjectStyle.textFramePreferences.autoSizingReferencePoint = AutoSizingReferenceEnum.TOP_CENTER_POINT; //Change if necessary

    myObjectStyle.enableFill = false;
    myObjectStyle.enableStroke = false;
    myObjectStyle.enableStrokeAndCornerOptions = false;
    myObjectStyle.enableParagraphStyle = false;
    myObjectStyle.enableTextFrameGeneralOptions = false;
    myObjectStyle.enableTextFrameBaselineOptions = false;
    myObjectStyle.enableStoryOptions = false;
    myObjectStyle.enableTextWrapAndOthers = false;
    myObjectStyle.enableAnchoredObjectOptions = false;
    myObjectStyle.enableFrameFittingOptions = false;

    }
    // Apply ObjectStyle to the selection
    var myObject = app.selection[0];
    myObject.appliedObjectStyle = myObjectStyle;

    in reply to: color labels and style ? #100908
    Vinny –
    Member

    Bonjour Nicolas
    Si je comprends bien, c’est plutôt un “aperçu” que tu souhaites, plutôt qu’appliquer un soulignement coloré qui sera bien évidemment visible à l’export.
    Il existe un magnifique script (gratuit, qui plus est) écrit par Marc Autret qui fait exactement ce que tu souhaites:
    Voir ici:
    https://creativepro.com/style-highlighting.php

    in reply to: No line breaks in TOC #100901
    Vinny –
    Member

    Hey Peter
    I think I answered a bit too fast yesterday… Was kinda thinking out loud.
    About the issue of Chapters with no subheaders, forget about what I said. Simply create a new para style based on “Chapter”. Call it i.e. “Chapter with no subheader”. Just apply it to your 2 paragraphs Chapter 2 and add it as as new entry in your TOC.
    Also, I had a look at your TOC screenshot and like to share a thought: in your TOC Chapter para stle, make sure you set up your tabs properly: first tab must allow enough space in case you have a two (or more?) digits chapter number. Second tab must be right aligned up to your frame.

    in reply to: No line breaks in TOC #100884
    Vinny –
    Member

    Hi Peter
    Yes… so close ^^
    For your first issue, start by setting a “magical” character style. Let’s call it “invisible”. Set it as follows: 0.1pt font size, no color, 1% horizontal scaling and -1000 approach. This character style will come so handy in so many GREP tricks that I’m sure you won’t be able to live without it^^
    Then apply this character style to the page number and the semicolon using this grep style query:
    Nyckel\d+\K\d+;

    Now, for the second issue… that’s a bummer but let’s see if we can solve this.
    So, just create a new paragraph in chapter 2 and type “hidden”, then apply Subheader paragraph style.
    Now add grep style to your Subheader para style:
    hidden\v
    and apply… “invisible” character style of course. I told you you won’t be able to live without it ^^
    Of course, don’t forget to add the same grep style to your TOC subheader style.

    Let’s be clear, this is not so great to have this kind of hidden text in your document. You might accidentally delete it for example. So, be cautious…

    Hmm Ok… You have a new issue now? Some extra spacing before and after the “hidden” subheader, right? So you used Space before and/or after in your para style. Unfortunately, those properties are paragraph ones, not characters, and for the moment, I can’t think of another trick to get rid of them.
    If you didn’t use space before and after, well, good for you, you should be nearly done then…

    Hope that helps
    Vinny

    in reply to: No line breaks in TOC #100857
    Vinny –
    Member

    Hey. Well I won’t be in front of my computer before Thursday but I still can explain briefly how it may be possible to achieve what you want.
    About setting the entries inline, it’s very easy to do. Juste check “Run in” Toc option. This will display the entries inline, with a semicolon and a space as separators. A grep trick could turn it into a fake dash. (Oops, a typography expert just had a heart attack…).
    The trickiest part is to get the chapter number and chapter header in the same line. Well, it’s basically not possible, so I just replaced chapter header para style by existing chapter number para style. Grep styles are faking the formatting. Now, these 2 entries can be set up inline since they use the same style. Grep styling again to hide page number and separator between these 2:entries.
    Got it?

    in reply to: No line breaks in TOC #100844
    Vinny –
    Member

    Hi there… Maybe Santa was just late?
    Question is: are subheaders always placed before training tips in your document?
    If so, I guess it would be doable… just need some GREP magic…
    I got to go know, but I can explain this on Thursday ^^

    TOC

    in reply to: Grep replace: #100816
    Vinny –
    Member

    Hi,
    What about this?
    Find
    .*Morita.*\v?
    Replace by nothing

Viewing 15 posts - 76 through 90 (of 92 total)