• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

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

Advocate ,
Feb 14, 2017 Feb 14, 2017

Copy link to clipboard

Copied

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.textContainers; 

            for(var m=_storyAllTextFrames.length-1;m>=0;m--){

                //If the contents of a text frame is an empty string: 

if(_storyAllTextFrames.contents === ""){ 

_storyAllTextFrames.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.

TOPICS
Scripting

Views

442

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Mentor , Feb 14, 2017 Feb 14, 2017

Hi,

use app.generalPreferences property:

preventSelectingLockedItemsboolr/wControls whether or not you can select and interact with a locked item. When this is off, only position is locked.

Jarek

Votes

Translate

Translate
Mentor ,
Feb 14, 2017 Feb 14, 2017

Copy link to clipboard

Copied

Hi,

use app.generalPreferences property:

preventSelectingLockedItemsboolr/wControls whether or not you can select and interact with a locked item. When this is off, only position is locked.

Jarek

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advocate ,
Feb 15, 2017 Feb 15, 2017

Copy link to clipboard

Copied

Thank you

I added between line 56/57 app.generalPreferences.preventSelectingLockedItems = false; and it still does not work.  Where should i place it?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Mentor ,
Feb 15, 2017 Feb 15, 2017

Copy link to clipboard

Copied

Hi,

Did you include a property "locked: true" while adding a tF? (line 66)

Jarek

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advocate ,
Feb 15, 2017 Feb 15, 2017

Copy link to clipboard

Copied

LATEST

PERFECT thank you I had forgotten to lock the Stinking Text frame.  Works Perfect now.  Thank you Very Much

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines