9 Replies Latest reply on Apr 8, 2008 5:32 PM by (Olav_Kvern)

    (JS] (CS2) AppliedObjectStyle

    CTC Imaging Level 1
      Hello everyone,

      I was wondering how I could OVERWRITE all properties of the ObjectStyle?

      At the moment, it is applying but NOT overwriting!!!

      **********************
      myPasteBox.appliedObjectStyle.defaultTextObjectStyle = app.objectStyles.item('[Normal Text Frame]');
      myPasteBox.appliedObjectStyle = myPasteBox.appliedObjectStyle.defaultTextObjectStyle;
        • 1. Re: (JS] (CS2) AppliedObjectStyle
          Level 1
          from VB6 ObjectBrowser:

          Sub ApplyObjectStyle(Using As ObjectStyle, [ClearingOverrides As Boolean = True], [ClearingOverridesThroughRootObjectStyle As Boolean = False])
          Member of InDesign.Rectangle
          Apply an object style / Using: the object style / ClearingOverrides: If applying an object style, whether to clear any attributes before applying the style / ClearingOverridesThroughRootObjectStyle: If applying an object style, whether to clear unchecked category attributes through the root style


          robin

          --
          www.adobescripts.com
          • 2. Re: (JS] (CS2) AppliedObjectStyle
            CTC Imaging Level 1
            Unfortunately, I am using CS2 and there is no applyObjectStyle method available. I believe this is new to CS3
            • 3. Re: (JS] (CS2) AppliedObjectStyle
              Level 1
              Hi Alexandre,

              CS2 has the applyObjectStyle method. Try this:

              main();
              function main(){
              var myDocument = app.documents.add();
              myDocument.viewPreferences.horizontalMeasurementUnits = MeasurementUnits.points;
              myDocument.viewPreferences.verticalMeasurementUnits = MeasurementUnits.points;
              var myObjectStyle = myDocument.objectStyles.add({name:"myObjectStyle"});
              var myRectangle = myDocument.pages.item(0).rectangles.add({geometricBounds:[72, 72, 144, 144]});
              myRectangle.applyObjectStyle(myObjectStyle, true);
              }
              Thanks,

              Ole
              • 4. Re: (JS] (CS2) AppliedObjectStyle
                Level 1
                I've copied this from CS2 reference library

                this works fine for me:

                '##############
                Set myInDi = CreateObject("InDesign.Application.CS2")
                Set myDoc = myInDi.ActiveDocument

                call myindi.selection.item(1).applyobjectstyle(mydoc.objectstyles.item("QQ"),true,false)
                '##############

                yes, there is NO info about ApplyObjectStyle in ScriptingReference to ID CS2 (20 MB PDF, 1898 pages), but script works fine :)

                robin

                --
                www.adobescripts.com
                • 5. Re: (JS] (CS2) AppliedObjectStyle
                  CTC Imaging Level 1
                  While reading CS3 script Guide, I've noticed code like removexxx() and addxxx() methods and they looked like redundant methods of xxx.remove() & xxx.add(). Am I correct? Is there a lot of those extra methods?
                  The one we are talking about is different though, since there is no objectStyle.apply() method. And also, I am guessing the Boolean is the overwrite.

                  Thank you, Alex.
                  • 6. Re: (JS] (CS2) AppliedObjectStyle
                    Level 1
                    Hi Robin,

                    It wasn't mentioned because it wasn't added until one of the first patches for CS2--well after the reference was built.

                    Hi Alexandre,

                    re: redundant methods in CS3 Guide

                    I'm not sure what you're talking about. Could you provide an example?

                    re: "The one we are talking about is different though, since there is no objectStyle.apply() method. And also, I am guessing the Boolean is the overwrite."

                    It's pageItem.applyObjectStyle() in CS3; pageItem.applyStyle() in CS2. Setting the boolean parameter to true overrides local formatting applied to the object.

                    Thanks,

                    Ole
                    • 7. Re: (JS] (CS2) AppliedObjectStyle
                      CTC Imaging Level 1
                      Olev, I was reading about eventListener and the provided samples. I dd not have the Javascript samples here at home. But to add an event it looks like you can do it 2 ways:

                      1) app.addEventListener( "afterOpen", EventOpen, true);
                      or
                      2) app.EventListener.add( "afterOpen", EventOpen, true);

                      same with remove. Also the CS3 guide (addendum) only mentions the .add() & so forth. I believe.

                      Here at home I have no reference PDF so I an going by memory.
                      Alex.
                      • 8. Re: (JS] (CS2) AppliedObjectStyle
                        CTC Imaging Level 1
                        I see my error. I was on a textFrame and should have been pointing on the pageItem instead!!!
                        Correct?
                        • 9. Re: (JS] (CS2) AppliedObjectStyle
                          Level 1
                          Hi Alexandre,

                          I think that's the only place it occurs--our event stuff is based on the W3C event model:

                          http://www.w3.org/TR/DOM-Level-2-Events/events.html

                          ...so we had to include those alternate add/remove methods.

                          Thanks,

                          Ole