当前位置:网站首页>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.作者寄语
合理的脚本代码可以有效的提高工作效率,减少重复劳动。
边栏推荐
- LeetCode_ 67 (binary sum)
- Thymeleaf common functions
- C语言中限定符的作用
- 直播预告|如何借助自动化工具落地DevOps(文末福利)
- Introduction, installation, introduction and detailed introduction to postman!
- 无密码身份验证如何保障用户隐私安全?
- Faire un clip vidéo auto - média deux fois, comment clip n'est pas considéré comme une infraction
- 【NVMe2.0b 14-9】NVMe SR-IOV
- ASP.NET大型外卖订餐系统源码 (PC版+手机版+商户版)
- 循环不变式
猜你喜欢
FR练习题目---简单题
PyTorch二分类时BCELoss,CrossEntropyLoss,Sigmoid等的选择和使用
网上电子元器件采购商城:打破采购环节信息不对称难题,赋能企业高效协同管理
SaaS multi tenant solution for FMCG industry to build digital marketing competitiveness of the whole industry chain
Intelligent supply chain collaboration system solution for daily chemical products industry: digital intelligent SCM supply chain, which is the "acceleration" of enterprise transformation
Thymeleaf th:classappend attribute append th:styleappend style append th:data- custom attribute
想进阿里必须啃透的12道MySQL面试题
There is a powerful and good-looking language bird editor, which is better than typora and developed by Alibaba
CYCA少儿形体礼仪 宁波市培训成果考核圆满落幕
Principle and performance analysis of lepton lossless compression
随机推荐
World Environment Day | Chow Tai Fook serves wholeheartedly to promote carbon reduction and environmental protection
一网打尽异步神器CompletableFuture
两个BI开发,3000多张报表?如何做的到?
Topology visual drawing engine
js亮瞎你眼的日期选择器
乌卡时代下,企业供应链管理体系的应对策略
手写promise与async await
日化用品行业智能供应链协同系统解决方案:数智化SCM供应链,为企业转型“加速度”
【学习笔记】阶段测试1
黑马程序员-软件测试-10阶段2-linux和数据库-44-57为什么学习数据库,数据库分类关系型数据库的说明Navicat操作数据的说明,Navicat操作数据库连接说明,Navicat的基本使用,
Webrtc learning (II)
申请代码签名证书时如何选择合适的证书品牌?
Lepton 无损压缩原理及性能分析
Thymeleaf 使用后台自定义工具类处理文本
Solution of commercial supply chain collaboration platform in household appliance industry: lean supply chain system management, boosting enterprise intelligent manufacturing upgrading
Penetration testing methodology
Thymeleaf 模板的创建与使用
Total amount analysis accounting method and potential method - allocation analysis
How to protect user privacy without password authentication?
想进阿里必须啃透的12道MySQL面试题