当前位置:网站首页>Photoshop插件-动作相关概念-ActionList-ActionDescriptor-ActionList-动作执行加载调用删除-PS插件开发
Photoshop插件-动作相关概念-ActionList-ActionDescriptor-ActionList-动作执行加载调用删除-PS插件开发
2022-07-05 14:34:00 【插件开发】
文章目录
1.简介
PS动作是什么?是一组操作步骤的组合,多个步骤集合成一两步操作完成复杂的操作。在PS内,是通过动作面板进行管理,录制,编辑,加载和执行。如下图所示:
2.动作相关概念
2.1.ActionDescriptor
该对象提供了一种字典式的机制,用于将数据存储为键值对。 它可用于对 Photoshop 的低级访问。许多配置文件使用序列化操作描述符来表示其数据。 例如,用于在 Application.playbackParameters 中封装播放选项,并由Application.getCustomOptions()。
2.2.ActionList
该对象提供了一种用于存储数据的数组式机制。 它可用于对 Photoshop 的低级访问。当存储相同类型的数据时,这个对象是理想的。 列表中的所有项目必须属于同一类型。 您可以使用诸如 putBoolean() 之类的“put”方法来附加新元素,并且可以使用 clear() 清除整个列表,但不能以其他方式修改列表。注意:ActionList 对象是 Action Manager 功能的一部分。 有关使用动作管理器的详细信息,请参阅 Photoshop CC 脚本指南。
2.3.ActionReference
此对象提供有关操作所指内容的信息。 例如,当提到某物的名称时,您可能会使用 keyName。 引用还需要知道您指的是什么名称。 在这种情况下,您可以使用 classDocument 作为文档名称或使用 classLayer 作为图层名称。 它可用于对 Photoshop 的低级访问。包含与 ActionDescriptor 关联的数据。
3.范例
3.1.加载动作
将动作文件加载至面板,代码如下所示:
app.load(File("C:\\2.atn"));
3.2.执行动作
调用函数执行对应组和对应名称函数,代码如下所示:
play_action("默认动作", "四分颜色");
//play_action("默认动作", "四分颜色") // Perform the whole action// 执行整个动作
//play_action("默认动作", "四分颜色", 4, true) // Complete all from the beginning of the command number 4// 从命令编号4 的开头全部完成
//play_action("默认动作", "四分颜色", 5, false) // Will execute only command number 5// 仅执行命令编号5
//cmd_number - the index of the command, ( starts from 1 )
function play_action(set, action, cmd_number, allow_continue)
{
try
{
var d = new ActionDescriptor();
var r = new ActionReference();
if (typeof(cmd_number) == "number") r.putIndex( charIDToTypeID( "Cmnd" ), cmd_number );
r.putName( charIDToTypeID( "Actn" ), action );
r.putName( charIDToTypeID( "ASet" ), set );
d.putReference( charIDToTypeID( "null" ), r );
if (typeof(allow_continue) == "boolean") d.putBoolean( charIDToTypeID( "Cntn" ), allow_continue );
executeAction( charIDToTypeID( "Ply " ), d, DialogModes.NO );
}
catch(e)
{
alert(e);
}
}
3.3.非加载执行动作文件中动作
通过非加载方式,执行动作文件中的动作,代码流程较长,有专门博文介绍。https://anjingzhi.blog.csdn.net/article/details/121544253
3.4.删除动作集
通过名称删除动作集。代码如下:
delete_actionset("组 1");
function delete_actionset(set)
{
try
{
var idDlt = charIDToTypeID( "Dlt " );
var desc24 = new ActionDescriptor();
var idnull = charIDToTypeID( "null" );
var ref5 = new ActionReference();
var idASet = charIDToTypeID( "ASet" );
ref5.putName( idASet, set );
desc24.putReference( idnull, ref5 );
executeAction( idDlt, desc24, DialogModes.NO );
}
catch(e)
{
alert(e);
}
}
3.5.删除动作
通过动作集和动作名称删除动作。代码如下:
delete_action("组 1","动作 1");
function delete_action(set,action)
{
try
{
var idDlt = charIDToTypeID( "Dlt " );
var desc6 = new ActionDescriptor();
var idnull = charIDToTypeID( "null" );
var ref3 = new ActionReference();
var idActn = charIDToTypeID( "Actn" );
ref3.putName( idActn, action );
var idASet = charIDToTypeID( "ASet" );
ref3.putName( idASet, set);
desc6.putReference( idnull, ref3 );
executeAction( idDlt, desc6, DialogModes.NO );
}
catch(e)
{
alert(e);
}
}
4.作者寄语
合理的脚本代码可以有效的提高工作效率,减少重复劳动。
边栏推荐
猜你喜欢
用 Go 跑的更快:使用 Golang 为机器学习服务
ASP.NET大型外卖订餐系统源码 (PC版+手机版+商户版)
FR练习题目---简单题
实现一个博客系统----使用模板引擎技术
申请代码签名证书时如何选择合适的证书品牌?
家用电器行业商业供应链协同平台解决方案:供应链系统管理精益化,助推企业智造升级
Thymeleaf th:classappend attribute append th:styleappend style append th:data- custom attribute
Online electronic component purchasing Mall: break the problem of information asymmetry in the purchasing process, and enable enterprises to effectively coordinate management
APR protocol and defense
基于TI DRV10970驱动直流无刷电机
随机推荐
LeetCode_ 69 (square root of x)
FR练习题目---综合题
Assembly language
做自媒体视频二次剪辑,怎样剪辑不算侵权
Topology可视化绘图引擎
Isn't it right to put money into the external market? How can we ensure safety?
Implement a blog system -- using template engine technology
Enjoy what you want. Zhichuang future
总量分析 核算方法和势方法 - 分摊分析
非技术部门,如何参与 DevOps?
一网打尽异步神器CompletableFuture
Thymeleaf 模板的创建与使用
ASP. Net large takeout ordering system source code (PC version + mobile version + merchant version)
两个BI开发,3000多张报表?如何做的到?
PHP - fatal error: allowed memory size of 314572800 bytes exhausted
Strong connection component
R language ggplot2 visual density map: Visual density map by group and custom configuration geom_ The alpha parameter in the density function sets the image transparency (to prevent multiple density c
Penetration testing methodology
webRTC SDP mslabel lable
What about SSL certificate errors? Solutions to common SSL certificate errors in browsers