3 Replies Latest reply: Aug 17, 2012 10:05 PM by greenrookie RSS

    Loading personal preferences

    greenrookie Community Member

      Hi everyone,

       

      This is from an old post from 2009 originally in the InDesign forum, http://forums.adobe.com/thread/451768?start=0&tstart=0

       

      This JS that Harbs wrote works great for me in IDCS4.

       

       

      try{SetPrefs()}
      catch(e){}

      function SetPrefs(){
        var e;
        var doc=app.documents[0];
        doc.viewPreferences.properties= {
          horizontalMeasurementUnits : MeasurementUnits.points,
          verticalMeasurementUnits : MeasurementUnits.points,
          rulerOrigin : RulerOrigin.PAGE_ORIGIN,
          cursorKeyIncrement : 1
        };
          
        doc.textPreferences.properties = {
          superscriptPosition : 33.3,
          superscriptSize : 65,
          subscriptPosition : 33.3,
          subscriptSize : 65,
          smallCap : 75,
          baselineShiftKeyIncrement : 0.1,
          leadingKeyIncrement : 0.1
        }
          
        var styleProps = {
          composer : "Adobe Single-line Composer",
          minimumWordSpacing : 85,
          desiredWordSpacing : 100,
          maximumWordSpacing : 133,
          minimumLetterSpacing : 0.0,
          desiredLetterSpacing : 0.0,
          maximumLetterSpacing : 0.0,
          hyphenateAfterFirst : 2,
          hyphenateBeforeLast : 3,
          hyphenateLadderLimit : 2,
          hyphenateCapitalizedWords : true
        }
        try{var styles=doc.allParagraphStyles;}
        catch(e){var styles = doc.paragraphStyles}
        for(var i=1;i<styles.length;i++){
          styles[i].properties=styleProps;
        }
      }

       

      Is there a way to make this script toggle between the custom settings here, then setting them back to the original document settings?

       

      Many thanks,

       

      gr

        • 1. Re: Loading personal preferences
          Harbs. MVP

          To do that, you're going to have to write the original settings somewhere in the doc.

           

          Harbs

          • 2. Re: Loading personal preferences
            greenrookie Community Member

            Thank you Harbs. Sorry I mean I just want to toggle between two sets of values (the templates the designers use always have the same preferences)

             

            e.g.

             

            MeasurementUnits between points and millimeters

            leadingKeyIncrement between 5 and 1

             

            etc.

             

            Right now I just use your script twice; one with my preferred values and after I'm done and ready to pass the file back to designers, I click on the other one which restores the values set on the template.

            • 3. Re: Loading personal preferences
              greenrookie Community Member

              patched together, but works for me : )

               

              var myDoc = app.activeDocument;

                  var myDocVerticalUnits = myDoc.viewPreferences.verticalMeasurementUnits;

                  var myDocHorizontalUnits = myDoc.viewPreferences.horizontalMeasurementUnits;

                  var myNewUnits = myDoc.viewPreferences;

               

                  switch (myDocVerticalUnits)

                  {

                      case 2053991795:  

                          myNewUnits.verticalMeasurementUnits = MeasurementUnits.picas;

                          break;

                      case 2054188905:

                          myNewUnits.verticalMeasurementUnits = MeasurementUnits.millimeters;

                          break;

                      default:  //apply for anything else millimeters as ruler units.

                          myNewUnits.verticalMeasurementUnits = MeasurementUnits.millimeters;

                          break;

                  }

                  switch (myDocHorizontalUnits)

                  {

                      case 2053991795:  

                          myNewUnits.horizontalMeasurementUnits = MeasurementUnits.picas;

                          break;

                      case 2054188905:

                          myNewUnits.horizontalMeasurementUnits = MeasurementUnits.millimeters;

                          break;

                      default:  //apply for anything else millimeters as ruler units.

                          myNewUnits.horizontalMeasurementUnits = MeasurementUnits.millimeters;

                          break;

                  }

               

              if (myDoc.viewPreferences.horizontalMeasurementUnits == MeasurementUnits.millimeters &&

              myDoc.viewPreferences.verticalMeasurementUnits == MeasurementUnits.millimeters)

              {myDoc.textPreferences.properties = {

                  baselineShiftKeyIncrement : 0.1,

                  leadingKeyIncrement : 0.1,

                  kerningKeyIncrement : 1

                };

                }

              else {myDoc.textPreferences.properties = {

                  baselineShiftKeyIncrement : 0.5,

                  leadingKeyIncrement : 0.5,

                  kerningKeyIncrement : 5

                };

                }