当前位置:网站首页>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:881. lifeboat

循环不变式

Thymeleaf th:with use of local variables

Loop invariant

Niuke: intercepting missiles

Implement a blog system -- using template engine technology

Countermeasures of enterprise supply chain management system in UCA Era

freesurfer运行完recon-all怎么快速查看有没有报错?——核心命令tail重定向

想进阿里必须啃透的12道MySQL面试题

Microframe technology won the "cloud tripod Award" at the global Cloud Computing Conference!
随机推荐
总量分析 核算方法和势方法 - 分摊分析
非技术部门,如何参与 DevOps?
Countermeasures of enterprise supply chain management system in UCA Era
有一个强大又好看的,赛过Typora,阿里开发的语雀编辑器
PostgreSQL 13 installation
freesurfer运行完recon-all怎么快速查看有没有报错?——核心命令tail重定向
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
MySQL user-defined function ID number to age (supports 15 / 18 digit ID card)
R language ggplot2 visual bar graph: visualize the bar graph through the two-color gradient color theme, and add label text for each bar (geom_text function)
手写promise与async await
FR练习题目---简单题
快消品行业SaaS多租户解决方案,构建全产业链数字化营销竞争力
01. Solr7.3.1 deployment and configuration of jetty under win10 platform
实现一个博客系统----使用模板引擎技术
两个BI开发,3000多张报表?如何做的到?
Assembly language
Intelligent supply chain collaboration system solution for daily chemical products industry: digital intelligent SCM supply chain, which is the "acceleration" of enterprise transformation
启牛证券账户怎么开通,开户安全吗?
Isn't it right to put money into the external market? How can we ensure safety?
直播预告|如何借助自动化工具落地DevOps(文末福利)