15 Replies Latest reply on Jul 7, 2017 7:24 PM by vinays28491172

    Need a way to hide a layer in a document from UI

    vinays28491172

      Hi experts,

       

      I have a requirement to add a Text to layer and make it uneditable to user.

       

      I have successfully tried to Lock, hide, diable edit layers as well as textFrame inside the layer via Scripting. However in Illustrator UI,  when user opens the document, user has the option to make the layer or Frame editable which is locked by scripting..

       

      So, looking for an option to lock, hide the layer via Scripting and also have no option for user to unlock or make visible  from UI.

       

       

      Here is the code I used:

       

      // Finds the tags associated with the selected art item,

      // show names and values in a separate document

      if ( app.documents.length > 0 )

      {

          doc = app.activeDocument;

          if ( doc.selection.length > 0 )

          {

                  for ( i = 0; i < doc.selection.length; i++ )

                  {

                              selectedArt = selection[0];

                              tagList = selectedArt.tags;

                              if (tagList.length == 0)

                              {

                                      var tempTag = tagList.add();

                                      tempTag.name = "OneWord";

                                      tempTag.value = "anything you want";

                               }

                   }      

              // Create a document and add a line of text per tag

              var reportDocument = app.documents.add();

              top_offset = 400;

            

              for ( i = 0; i < tagList.length; i++ )

              {

                          tagText = tagList[i].value;

                          newItem = reportDocument.textFrames.add();

                          newItem.contents = "Tag: (" + tagList[i].name +

                          " , " + tagText + ")";

                          newItem.position = Array(100, top_offset);

                          newItem.enableAccess = false;

                          newItem.editable = false;

                          newItem.locked = true;

                          newItem.hidden = true;

                          newItem.layer.visible = false;

                          newItem.layer.opacity = 0;

                          newItem.layer.preview = false;

                          newItem.layer.locked = true;

                          newItem.layer.enable=false;

                          newItem.layer.requirePermissionPassword = true;

                          newItem.layer.permissionPassword = "Vinnudear";

                          newItem.textRange.size = 24;

                          top_offset = top_offset - 20;

                         // newItem.layer.parent.save();

              //newItem.layer.parent.saveNoUI("c:\\temp\\LockTest.ai");

              //newItem.layer.parent.requirePermissionPassword = true;

              //newItem.layer.parent.permissionPassword = "teamcenter";

              newItem.note = "USER:VINAY";

              alert(newItem.note);

              } 

          }

      }

       

      Regards,

      Vinay

       

      Message was edited by: Vinay Seera