当前位置:网站首页>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.作者寄语
合理的脚本代码可以有效的提高工作效率,减少重复劳动。
边栏推荐
- Which Internet companies are worth going to in Shenzhen for software testers [Special Edition for software testers]
- Thymeleaf 使用后台自定义工具类处理文本
- [summary of leetcode weekly competition] the 81st fortnight competition of leetcode (6.25)
- PMP考试20天能通过吗?
- openGauss数据库源码解析系列文章—— 密态等值查询技术详解(下)
- R Language ggplot2 Visualization: visualize linegraph, using Legend in Theme function. Paramètre de position emplacement de la légende personnalisée
- 循环不变式
- 2022年国内正规的期货公司平台有哪些啊?方正中期怎么样?安全可靠吗?
- How to protect user privacy without password authentication?
- 【华为机试真题详解】欢乐的周末
猜你喜欢
浅谈Dataset和Dataloader在加载数据时如何调用到__getitem__()函数
Intelligent supply chain collaboration system solution for daily chemical products industry: digital intelligent SCM supply chain, which is the "acceleration" of enterprise transformation
World Environment Day | Chow Tai Fook serves wholeheartedly to promote carbon reduction and environmental protection
Sharing the 12 most commonly used regular expressions can solve most of your problems
SaaS multi tenant solution for FMCG industry to build digital marketing competitiveness of the whole industry chain
Thymeleaf 模板的创建与使用
无密码身份验证如何保障用户隐私安全?
CYCA少儿形体礼仪 宁波市培训成果考核圆满落幕
Implement a blog system -- using template engine technology
乌卡时代下,企业供应链管理体系的应对策略
随机推荐
有一个强大又好看的,赛过Typora,阿里开发的语雀编辑器
Thymeleaf th:with局部变量的使用
基于TI DRV10970驱动直流无刷电机
无密码身份验证如何保障用户隐私安全?
World Environment Day | Chow Tai Fook serves wholeheartedly to promote carbon reduction and environmental protection
C language -- structure and function
矩阵链乘 - 动态规划实例
黑马程序员-软件测试-10阶段2-linux和数据库-44-57为什么学习数据库,数据库分类关系型数据库的说明Navicat操作数据的说明,Navicat操作数据库连接说明,Navicat的基本使用,
Thymeleaf common functions
How does redis implement multiple zones?
[learning notes] stage test 1
leetcode:881. 救生艇
如何将电脑复制的内容粘贴进MobaXterm?如何复制粘贴
Thymeleaf 模板的创建与使用
mysql8.0JSON_CONTAINS的使用说明
Total amount analysis accounting method and potential method - allocation analysis
分享 12 个最常用的正则表达式,能解决你大部分问题
【招聘岗位】软件工程师(全栈)- 公共安全方向
想进阿里必须啃透的12道MySQL面试题
Is the securities account given by the head teacher of qiniu school safe? Can I open an account?