4 Replies Latest reply on Feb 15, 2017 1:05 PM by cbishop01

    Is there a way to lock postition and still beable to paste Pictures in text frames?

    cbishop01 Level 2

      Hello all,

      Is there a way to lock the position of a text frame but still be able to paste Pictures/Bar codes/ anything inside it? I have the below script placing the Text frame where i want it.  But i want it to stay in that position.  So no one can accidentally move or manipulate the text frame (Other than paste Graphics inside)

          #targetengine "AutoStartScript" 
      
      
       app.addEventListener( "beforeSave" , dotFOnPageOne );  
       app.addEventListener( "beforeSave", doMLyer );
      //>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>Move to layer<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<\\  
      
          function doMLyer(){
              layers = app.documents[0].layers;  
          if (layers.item('OUR Barcode').isValid) {  
            layers.item('OUR Barcode').move (LocationOptions.AT_BEGINNING); 
          } 
      }
        
      //>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>CREATE NEW layer FOR SAVE CHANGES<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<\\  
          function doLyer(){
              var _d = app.documents[0];  
              var _allStories = _d.stories;  
              for(var n=_allStories.length-1;n>=0;n--){  
              var _storyAllTextFrames = _allStories[n].textContainers;  
                  for(var m=_storyAllTextFrames.length-1;m>=0;m--){ 
                      //If the contents of a text frame is an empty string:  
       if(_storyAllTextFrames[m].contents === ""){  
       _storyAllTextFrames[m].select();  
       //Convert frame to "Unassigned":  
                /*      try{ 
       app.scriptMenuActions.itemByID(11297).invoke();  
       }catch(e){};  */
       };  
       };  
                  };  
                
              //Trick to deselect the last selection  
              //Add a new textFrame, select and remove it:  
              var _tempTextFrame = _d.textFrames.add();  
       _tempTextFrame.select();  
       _tempTextFrame.remove();  
             }
      //>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>NEW layer Color Settings<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<\\  
          function addlayer(doc, name){  
              try{  
                  var layer = doc.layers.itemByName(name);  
                  if(layer && layer.isValid) {  
       return layer;  
                      } else {  
                  var mylayer = doc.layers.add();  
       mylayer.name = name; 
       mylayer.layerColor = [100,50,100]
                      return mylayer;  
              }  
            } catch(e) {  
           }  
          }  
      
      //>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>CREATE TEXT FRAME FOR SAVE INFO<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<\\ 
          function addTextF(doc, layer, name){  
              var myBlendingSettings = { blendMode : BlendMode.NORMAL };        
              var myTransparencySettings = { blendingSettings : myBlendingSettings }; 
                
              var tF = doc.textFrames.itemByName(name);  
              if(tF && tF.isValid) {        
       tF.remove();  
              }  
              var origUnit = app.scriptPreferences.measurementUnit; 
       app.scriptPreferences.measurementUnit = MeasurementUnits.INCHES;
              tF = doc.textFrames.add(layer, LocationOptions.UNKNOWN, {name: name, fillColor :"None", fillTint: 0, transparencySettings : myTransparencySettings,
                  geometricBounds: ['.65in','.062in','.23in','-.066'] }); 
       app.scriptPreferences.measurementUnit = origUnit;      
                    return tF;  
          }  
      
      //>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>MOVE TEXT FRAME TO layer<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<\\ 
          function dotFOnPageOne(event){       
                  
              var doc = event.target;     
              if(!(doc && doc.constructor.name == "Document")) {  
       return;  
              }  
                  
              var mylayer = addlayer(doc, "OUR Barcode");  
              var tF = addTextF(doc, mylayer, "OUR Barcode"); 
      
       }       
      
      
      

      Thanks for any help.