Copy link to clipboard
Copied
Hi experts,
I have a requirement to add a Text to layer and make it uneditable to user.
I have tried to Lock, hide, diable edit layers as well as textFrame inside the layer via Scripting, however in Illustrator UI, user has the option to make the layer or Frame editable which makes user to make changes.
So, looking for an option to lock, hide the layer 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.value;
newItem = reportDocument.textFrames.add();
newItem.contents = "Tag: (" + tagList.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
1 Correct answer
You may receive a better response at the Illustrator Scripting forum
Explore related tutorials & articles
Copy link to clipboard
Copied
You may receive a better response at the Illustrator Scripting forum
Copy link to clipboard
Copied
This discussion is locked. Please see duplicate post at Need a way to hide a layer in a document from UI .
