9 Replies Latest reply on Feb 12, 2018 3:05 AM by Laubender

    Where to find it? JSX CS3 Win

    Level 1
      As a relative newbie to InDesign scripting in JavaScript (JSX), I am having a hard time finding the right codes (classes, methods, whatever). The logic is less of a problem.

      For example, how did HorizontalMeasurementUnits end up in ViewPreferences? In InD the ruler units are under the Ruler Units in the Units and Increments preference.

      MeasurementUnits gives me the class element as POINTS, when points seems to work to describe the unit.

      I know the ESTK Object Model dialogue will auto-present options, but that's only if you have started down the right track.

      Reading 500 pages of sample scripts and references spread over 7 PDF documents just isn't very efficient when I don't know what I am looking for.

      I'm not complaining (much), I just want to know how others cope.
        • 1. Re: Where to find it? JSX CS3 Win
          [Jongware] Most Valuable Participant
          When pressed upon specifics, Olav Kvern usually can supply a good reason for just about any peculiarity in scripting (as he's one of its designers). :-)
          But I'd really like to see a graphical representation of the entire model.

          Where to find stuff: the ESTK 2 help isn't of much use if you're looking for "something like xxx" -- a free text search would really help. Fortunately, someone converted the Javascript help to HTML (well okay, it was me). See also this discussion.
          • 2. Re: Where to find it? JSX CS3 Win
            Level 1
            Many thanks Jongware!!

            b The link: indesigncs3jshelp.zip worked for me
            when the link: http://www.jongware.binaries.indesigncs3jshelp.zip didn't.

            Seeing the whole thing organized efficiently makes searching for "possibles" much, much easier.

            Now I have to find what a "constructor" is (another term found by accident).

            Thank God the truck number for InDesign scripting has now been raised by 1: Jongware.

            RS
            • 3. Re: Where to find it? JSX CS3 Win
              Level 1
              Actually, the link that worked for me was:

              b www.jongware.binaries.indesigncs3jshelp.zip

              RS
              • 4. Re: Where to find it? JSX CS3 Win
                [Jongware] Most Valuable Participant
                Actually, the proper link is

                http://www.jongware.com/binaries/indesigncs3jshelp.zip

                I wonder how that got mangled in the thread I pointed to
                i and
                in the 2 posts above!
                • 5. Re: Where to find it? JSX CS3 Win
                  Level 1
                  That one worked.
                  RS
                  • 6. Re: Where to find it? JSX CS3 Win
                    neal derekl34934377 Level 1

                    Just finished writing my first code ever from scratch with zero assistance and found that it was easier to search the DOM via google’s “site” feature.

                     

                    For example, searching the below terms helped me to find the File Handling preferences syntax (screenshot of results below):

                     

                    preview images files site:http://jongware.mit.edu/ -illustrator

                     

                    And it worked like a charm to hone in on my target.

                     

                    *as a side note, I’m positive the below code can be shortened, possibly under one catchall variable, and then grouping and listing out properties, etc.

                     

                    I was just so glad to have got anything working.

                     

                    If anyone wants to take a crack at it be my guest, I’m sure I would learn more from it.

                     

                    Thanks.

                     

                     

                     

                    /*
                        Standard Global Preferences Script
                        Neal Derek Lawson
                        v1.01
                        2018.02.11
                       
                        */
                    
                    
                    
                    
                    //View Preferences
                    myPrefs = app.parent.viewPreferences;
                    
                    
                    myPrefs.horizontalMeasurementUnits = MeasurementUnits.INCHES;
                    myPrefs.verticalMeasurementUnits = MeasurementUnits.INCHES;
                    
                    
                    myPrefs.guideSnaptoZone = 10;
                    
                    
                    myPrefs.cursorKeyIncrement = (".01 in");
                    
                    
                    myPrefs.rulerOrigin = RulerOrigin.SPREAD_ORIGIN;
                    
                    
                    
                    
                    //Pasteboard Preferences
                    myPboardPrefs = app.parent.pasteboardPreferences;
                    
                    
                    myPboardPrefs.pasteboardMargins = Array ("50 in", "50 in");
                    
                    
                    
                    
                    //Text Preferences
                    myTextPrefs = app.parent.textPreferences;
                    
                    
                    myTextPrefs.baselineShiftKeyIncrement = ("1 pt");
                    
                    
                    myTextPrefs.kerningKeyIncrement = 1;
                    
                    
                    myTextPrefs.leadingKeyIncrement = ("1 pt");
                    
                    
                    myTextPrefs.subscriptPosition = 0;
                    
                    
                    myTextPrefs.typographersQuotes = false;
                    
                    
                    
                    
                    
                    
                    //General Preferences
                    myGenPrefs = app.parent.generalPreferences;
                    
                    
                    myGenPrefs.includePreview = true;
                    
                    
                    myGenPrefs.previewPages = PreviewPagesOptions.FIRST_2_PAGES
                    
                    
                    myGenPrefs.previewSize = PreviewSizeOptions.EXTRA_LARGE
                    

                     

                     

                     

                    Google results screenshot.

                    Screen Shot 2018-02-11 at 20.25.06.png

                    • 7. Re: Where to find it? JSX CS3 Win
                      neal derekl34934377 Level 1

                      ....just answered my own question in terms of shortening the script.

                       

                      If there’s a way of shortening it further, by all means don’t hesitate to let me know. Thanks.

                       

                       

                      /*
                          Standard Global Preferences Script
                          Neal Derek Lawson
                          v1.01
                          2018.02.11
                         
                          */
                      
                      
                      //View Preferences
                      myPrefs = app.parent.viewPreferences;
                      
                      
                      myPrefs.properties = {
                      
                      
                      horizontalMeasurementUnits:MeasurementUnits.INCHES,
                      verticalMeasurementUnits:MeasurementUnits.INCHES,
                      
                      
                      guideSnaptoZone:10,
                      
                      
                      cursorKeyIncrement:(".01 in"),
                      
                      
                      rulerOrigin:RulerOrigin.SPREAD_ORIGIN
                      };
                      
                      
                      
                      
                      
                      
                      
                      
                      //Pasteboard Preferences
                      myPboardPrefs = app.parent.pasteboardPreferences;
                      
                      
                      myPboardPrefs.pasteboardMargins = Array ("50 in", "50 in");
                      
                      
                      
                      
                      //Text Preferences
                      myTextPrefs = app.parent.textPreferences;
                      
                      
                      myTextPrefs.properties = {
                      
                      
                      baselineShiftKeyIncrement:("1 pt"),
                      
                      
                      kerningKeyIncrement:1,
                      
                      
                      leadingKeyIncrement:("1 pt"),
                      
                      
                      subscriptPosition:0,
                      
                      
                      typographersQuotes:false
                      
                      
                      };
                      
                      
                      
                      
                      //General Preferences
                      myGenPrefs = app.parent.generalPreferences;
                      
                      
                      myGenPrefs.properties = {
                      
                      
                      includePreview:true,
                      
                      
                      previewPages:PreviewPagesOptions.FIRST_2_PAGES,
                      
                      
                      previewSize:PreviewSizeOptions.EXTRA_LARGE
                      
                      
                      };
                      
                      • 8. Re: Where to find it? JSX CS3 Win
                        [Jongware] Most Valuable Participant

                        Neal, nice start!

                         

                        You can also download the entire help for your version of InDesign (from CS up to CS6) as a Windows CHM file from my site: Indesign JavaScript Help (and it works even on a Mac, if you install one of the free CHM readers that are available). That way you can use its own Search functions; no need to Google.

                         

                        If you are using a modern InDesign (CC and later), you can use Gregor Fellenz' version of the JavaScript Reference. His site InDesign ExtendScript API (13.0) has an index and a search box online.

                        • 9. Re: Where to find it? JSX CS3 Win
                          Laubender Adobe Community Professional & MVP

                          Hi Neal,

                          just a question: Why do you write app.parent. and not simply app. ?
                          The parent of app is app.

                           

                          app.parent.version === app.version // returns true
                          

                           

                          ( Just a hint to make it even shorter  ;-) )

                           

                          Regards,
                          Uwe