5 Replies Latest reply on May 12, 2016 10:59 PM by CoverBuilder

    Code in jsx script to set Object Editing value

    jwilheim

      The software company where I work runs a .jsx script to set all Preferences in InDesign.

      InDesign CS 5.5 has an option under General for Object Editing named Prevent Selection of Locked Objects.

      We need to have this turned off every time a user creates a new document.

      Can some provide the code to this that we can add to our existing script? Thank you.

        • 1. Re: Code in jsx script to set Object Editing value
          absqua Level 4

          That's an application preference, not a document preference, so I don't understand why you would need to set it every time someone makes a new document.

           

          app.generalPreferences.preventSelectingLockedItems = false;
          

           

          is what you want. We can't tell you where to put it in your existing script unless you provide it.

           

          Jeff

          • 2. Re: Code in jsx script to set Object Editing value
            jwilheim Level 1

            Thanks for the quick response. Here is our current Java script, in full. Thought it references CS2 in a comment at the top, we have run it successfully with CS2, CS4, CS5 and CS5.5

            ----------------------------------------

            //ApplicationTextDefaults

            //An InDesign CS2 JavaScript

            //Sets the application text defaults, which will become the text defaults for all

            //new documents. Existing documents will remain unchanged.

            with(app.textDefaults){

                alignToBaseline = false;        // align to baseline grid

                try {

            //        appliedFont = app.fonts.item("Times New Roman");

                    appliedFont = app.fonts.item("Helvetica");

                }

                catch (e) {}

                try {

                    fontStyle = "Medium";

                }

                catch (e) {}

                autoleading = 100;

                balanceRaggedLines = false;

                baselineShift = 0;

                capitalization = Capitalization.normal;

                composer = "Adobe Paragraph Composer";

                desiredGlyphScaling = 100;

                desiredLetterSpacing = 0;

                desiredWordSpacing = 100;

                dropCapCharacters = 0;

                if (dropCapCharacters != 0) {

                    dropCapLines = 3;

                    //Assumes that the application has a default character style named "myDropCap"

                    //dropCapStyle = app.characterStyles.item("myDropCap");

                }

                fillColor = app.colors.item("Black");

                fillTint = 100;

                firstLineIndent = "0pt";

            //    firstLineIndent = "14pt";

                gridAlignFirstLineOnly = false;

                horizontalScale = 100;

                hyphenateAfterFirst = 3;

                hyphenateBeforeLast = 4;

                hyphenateCapitalizedWords = false;

                hyphenateLadderLimit = 1;

                hyphenateWordsLongerThan = 5;

                hyphenation = true;

                hyphenationZone = "3p";

                hyphenWeight = 9;

                justification = Justification.leftAlign;

                keepAllLinesTogether = false;

                keepLinesTogether = true;

                keepFirstLines = 2;

                keepLastLines = 2;

                keepWithNext = 0;

                kerningMethod = "Optical";

                kerningValue = 0;

                leading = 6.3;

            //    leading = 14;

                leftIndent = 0;

                ligatures = true;

                maximumGlyphScaling = 100;

                maximumLetterSpacing = 0;

                maximumWordSpacing = 160;

                minimumGlyphScaling = 100;

                minimumLetterSpacing = 0;

                minimumWordSpacing = 80;

                noBreak = false;

                otfContextualAlternate = true;

                otfDiscretionaryLigature = true;

                otfFigureStyle = OTFFigureStyle.proportionalOldstyle;

                otfFraction = true;

                otfHistorical = true;

                otfOrdinal = false;

                otfSlashedZero = true;

                otfSwash = false;

                otfTitling = false;

                overprintFill = false;

                overprintStroke = false;

                pointSize = 6.3;

            //    pointSize = 11;

                position = Position.normal;

                rightIndent = 0;

                ruleAbove = false;

                if(ruleAbove == true){

                    ruleAboveColor = app.colors.item("Black");

                    ruleAboveGapColor = app.swatches.item("None");

                    ruleAboveGapOverprint = false;

                    ruleAboveGapTint = 100;

                    ruleAboveLeftIndent = 0;

                    ruleAboveLineWeight = .25;

                    ruleAboveOffset = 14;

                    ruleAboveOverprint = false;

                    ruleAboveRightIndent = 0;

                    ruleAboveTint = 100;

                    ruleAboveType = app.strokeStyles.item("Solid");

                    ruleAboveWidth = RuleWidth.columnWidth;

                }

                ruleBelow = false;

                if(ruleBelow == true){

                    ruleBelowColor = app.colors.item("Black");

                    ruleBelowGapColor = app.swatches.item("None");

                    ruleBelowGapOverprint = false;

                    ruleBelowGapTint = 100;

                    ruleBelowLeftIndent = 0;

                    ruleBelowLineWeight = .25;

                    ruleBelowOffset = 0;

                    ruleBelowOverprint = false;

                    ruleBelowRightIndent = 0;

                    ruleBelowTint = 100;

                    ruleBelowType = app.strokeStyles.item("Solid");

                    ruleBelowWidth = RuleWidth.columnWidth;

                }

                singleWordJustification = SingleWordJustification.leftAlign;

                skew = 0;

                spaceAfter = 0;

                spaceBefore = 0;

                startParagraph = StartParagraph.anywhere;

                strikeThru = false;

                if(strikeThru == true){

                    strikeThroughColor = app.colors.item("Black");

                    strikeThroughGapColor = app.swatches.item("None");

                    strikeThroughGapOverprint = false;

                    strikeThroughGapTint = 100;

                    strikeThroughOffset = 3;

                    strikeThroughOverprint = false;

                    strikeThroughTint = 100;

                    strikeThroughType = app.strokeStyles.item("Solid");

                    strikeThroughWeight = .25;

                }

                strokeColor = app.swatches.item("None");

                strokeTint = 100;

                strokeWeight = 0;

                tracking = 0;

                underline = false;

                if(underline == true){

                    underlineColor = app.colors.item("Black");

                    underlineGapColor = app.swatches.item("None");

                    underlineGapOverprint = false;

                    underlineGapTint = 100;

                    underlineOffset = 3;

                    underlineOverprint = false;

                    underlineTint = 100;

                    underlineType = app.strokeStyles.item("Solid");

                    underlineWeight = .25

                }

                verticalScale = 100;

            }

            //

            //Units & Increments preference panel

            //Must do this to make sure our units that we set are in points. The vert and horiz

            //units that get set default to the current measurement unit. We set it to points

            //so we can be sure of the value. We'll reset it later to the desired setting.

            with(app.viewPreferences){

                horizontalMeasurementUnits = MeasurementUnits.points;    // Ruler Units, horizontal

                verticalMeasurementUnits = MeasurementUnits.points;        // Ruler Units, vertical

            }

            //

            //General preference panel

            with(app.generalPreferences){

                pageNumbering = PageNumberingOptions.section;    // Page Numbering, View

                toolTips = ToolTipOptions.normal;                    // Tool Tips

            //    toolsPalette = ToolsPaletteOptions.doubleColumn;    // Floating Tool Palette

                completeFontDownloadGlyphLimit = 2000;                // Always Subset Fonts...

            }

            //

            //Type preference panel

            with (app.textEditingPreferences){

                tripleClickSelectsLine = true;    // Triple Click to Select a Line

                smartCutAndPaste = true;        // Adjust Spacing Automatically when Cutting and Pasting Words

                dragAndDropTextInLayout = false;    // Enable in Layout View

                allowDragAndDropTextInStory = true;    // Enable in Story Editor

            }

            with(app.textPreferences){

                typographersQuotes = true;            // Use Typographer's Quotes

                useOpticalSize = true;                // Automatically Use Correct Optical Size

                scalingAdjustsText = true;            // Adjust Text Attributes when Scaling

                useParagraphLeading = false;    // Apply Leading to Entire Paragraphs

                linkTextFilesWhenImporting = false;    // Create Links when Placing Text and Spreadsheet Files

            }

            // Missing following (Font Preview Size, Past All Information/Text Only)

            //

            //Advanced Type preference panel

            with(app.textPreferences){

                superscriptSize = 58.3;                // Superscript, size

                superscriptPosition = 33.3;            // Superscript, position

                subscriptSize = 58.3;                // Subscript, size

                subscriptPosition = 33.3;            // Subscript, position

                smallCap = 70;                        // Smallcap

            }

            with(app.imePreferences){

                inlineInput = false;                // Use Inline Input for Non-Latin Text

            }

            //Composition preference panel

            with(app.textPreferences){

                highlightKeeps = false;                    // Keep Violations

                highlightHjViolations = false;            // H&J Violations

                highlightCustomSpacing = false;            // Custom Tracking/Kerning

                highlightSubstitutedFonts = true;    // Substituted Fonts

                highlightSubstitutedGlyphs = false;    // Substituted Glyphs

                justifyTextWraps = false;                // Justify Text Next to an Object

                abutTextToTextWrap = true;                // Skip by Leading

                zOrderTextWrap = false;                    // Text Wrap Only Affects Text Beneath

            }

            //

            //Units & Increments preference panel

            with(app.viewPreferences){

                rulerOrigin = RulerOrigin.spreadOrigin;                    // Ruler Units, origin

            //    These are set at the end of the script after all the changes have been made

            //    horizontalMeasurementUnits = MeasurementUnits.points;    // Ruler Units, horizontal

            //    verticalMeasurementUnits = MeasurementUnits.inches;        // Ruler Units, vertical

                pointsPerInch = 72;                    // Point/Pica Size, Points/Inch

                cursorKeyIncrement = 1;                // Keyboard Increment, Cursor Key

            }

            with(app.textPreferences){

                baselineShiftKeyIncrement = 2;    // Keyboard Increment, Baseline Shift

                leadingKeyIncrement = 2;        // Keyboard Increment, Size/Leading

                kerningKeyIncrement = 20;            // Keyboard Increment, Kerning

            }

            //

            //Grids preference panel

            with(app.gridPreferences){

                baselineColor = UIColors.lightBlue;    // Baseline Grid, Color

                baselineStart = 48;                        // Baseline Grid, Start

                baselineDivision = 6;                    // Baseline Grid, Increment Every

                baselineViewThreshold = 50;                // Baseline Grid, View Threshold

                baselineGridRelativeOption = BaselineGridRelativeOption.topOfPageOfBaselineGridRelativeOption;    // Baseline Grid, Relative To

                gridColor = UIColors.lightGray;            // Document Grid, Color

                horizontalGridlineDivision = 12;    // Document Grid, Horizontal, Gridline Every

                horizontalGridSubdivision = 12;            // Document Grid, Horizontal, Subdivisions

                verticalGridlineDivision = 12;            // Document Gird, Vertical, Gridline Every

                verticalGridSubdivision = 12;            // Document Grid, Vertical, Subdivisions

                gridsInBack = true;                        // Grids in Back

                //

                documentGridSnapto = false;                // snap to grid or not

                documentGridShown = false;                // show document grid

            }

            //

            //Guides & Pasteboard preference panel

            with(app.documentPreferences){

                marginGuideColor = UIColors.violet;                // Color, Margins

                columnGuideColor = UIColors.magenta;            // Color, Columns

            }

            with(app.pasteboardPreferences){

                bleedGuideColor = UIColors.fiesta;                // Color, Bleed

                slugGuideColor = UIColors.gridBlue;                // Color, Slug

                previewBackgroundColor = UIColors.lightGray;    // Color, Preview Background

                minimumSpaceAboveAndBelow = 72;                    // Minimum Vertical Offset

            }

            with(app.viewPreferences){

                guideSnaptoZone = 4;                            // Snap to Zone

            }

            with(app.guidePreferences){

                guidesInBack = false;                            // Guides in Back

            }

            //

            //Dictionary preference panel

            with(app.dictionaryPreferences){

                composition = ComposeUsing.both;    // Hyphenatin Exceptions, Compose Using

                mergeUserDictionary = false;    // Merge User Dictionary into Document

                recomposeWhenChanged = true;    // Recompose All Stories When Modified

            }

            // Missing (Lang, Hyph, Spelling, Double Quotes, Single Quotes)

            //

            //Spelling preference panel

            with(app.spellPreferences){

                checkMisspelledWords = true;                    // Find, Misspelled Words

                checkRepeatedWords = true;                        // Find, Repeated Words

                checkCapitalizedWords = true;                    // Find, Uncapitalized Words

                checkCapitalizedSentences = true;                // Find, Uncapitalized Sentences

                dynamicSpellCheck = true;                        // Enable Dynamic Spelling

                misspelledWordColor = UIColors.red;                // Color, Misspelled Words

                repeatedWordColor = UIColors.green;                // Color, Repeated Words

                uncapitalizedWordColor = UIColors.green;    // Color, Uncapitalized Words

                uncapitalizedSentenceColor = UIColors.green;    // Color, Uncapitalized Sentences

            }

            //

            //Autocorrect preference panel

            with(app.autoCorrectPreferences){

                autoCorrect = true;                            // Enable Autocorrect

                autoCorrectCapitalizationErrors = false;    // Autocorrect Capitalization

            }

            // Missing (Language, Misspelled word pairs)

            //

            //Display Performance preference panel

            with(app.displayPerformancePreferences){

                defaultDisplaySettings = ViewDisplaySettings.typical;    // Preserve Object-Level

                persistLocalSettings = false;

            }

            // Missing (antialiasiing, greek below

            //

            //Story Editor Display preference panel

            with(app.galleyPreferences){

                textColor = InCopyUIColors.black;                // Text Color

                backgroundColor = InCopyUIColors.white;            // Background

                smoothText = true;                                // Enable Anti-Aliasing

                antiAliasType = AntiAliasType.grayAntialiasing;    // Type

                cursorType = CursorTypes.standardCursor;    // Cursor Type

                blinkCursor = true;                                // Blink

            }

            // Missing (Font, Size, Line Spacing & Theme)

            //

            //File Handling preference panel

            with(app.generalPreferences){

                includePreview = true;                        // Always Save Preview Images with Doc

                previewSize = PreviewSizeOptions.medium;    // Preview Size

            }

            with(app.clipboardPreferences){

                preferPDFWhenPasting = false;                // Prefer PDF When Pasting

                copyPDFToClipboard = true;                    // Copy PDF to Clipboard

                preservePdfClipboardAtQuit = false;            // Preserve PDF Data at Quit

            }

            // Missing (Enable Version Cue)

            //

            //

             

            //

            //    Optical margin (hanging punctuation, outside margins)

            with(app.storyPreferences){

                opticalMarginAlignment = false;

                opticalMarginSize = 12;                // pts

            }

             

            //Wrap Up (do at end of script)

            //Units & Increments preference panel

            //Must do this to make sure our units that we set are in points. The vert and horiz

            //units that get set default to the current measurement unit. We set it to points

            //so we can be sure of the value. We'll reset it later to the desired setting.

            with(app.viewPreferences){

                horizontalMeasurementUnits = MeasurementUnits.picas;    // Ruler Units, horizontal

                verticalMeasurementUnits = MeasurementUnits.inches;    // Ruler Units, vertical

            }

            • 3. Re: Code in jsx script to set Object Editing value
              absqua Level 4

              Whew! You guys are serious about your preferences. You should insert the new one in the with block that starts at line 154:

               

              //General preference panel
              with(app.generalPreferences){
                  pageNumbering = PageNumberingOptions.section;    // Page Numbering, View
                  toolTips = ToolTipOptions.normal;                    // Tool Tips
              //    toolsPalette = ToolsPaletteOptions.doubleColumn;    // Floating Tool Palette
                  completeFontDownloadGlyphLimit = 2000;                // Always Subset Fonts...
                  preventSelectingLockedItems = false;
              }
              
              • 4. Re: Code in jsx script to set Object Editing value
                jwilheim Level 1

                Thanks for all your help. Our company writes software in Java that integrates with InDesign (or QuarkXPress) for selling and making the content of newspaper advertising -- everything from a single-line, text-only ad in the classifieds to double-truck, full-page ads for car dealers. We lock down the preferences for maximum efficiency with what our users do.

                • 5. Re: Code in jsx script to set Object Editing value
                  CoverBuilder Level 1

                  If

                      hyphenateAfterFirst = 3;

                      hyphenateBeforeLast = 4;

                   

                  Then

                      hyphenateWordsLongerThan = 5; // Will/Shoule be 7 right?