如何检查Photoshop Brush是否以编程方式存在 [英] How check if photoshop brush exist programmatically

查看:75
本文介绍了如何检查Photoshop Brush是否以编程方式存在的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试为某些操作创建一个Photoshop面板,但是我想知道如何检查画笔是否已经存在于Photoshop中,如果不存在,请在使用该操作之前调用一个函数来安装它,我已经知道如何安装它以及如何运行操作,但是在检测画笔是否在Mac/Windows环境中仍然存在一些问题.

I'm trying to create a Photoshop Panel for some actions, but I want to know how can I check if the brush already exist in photoshop and if not exist to call a function to install it before the action can be used, I already know how install it, and how run the actions, but I still got some issues detecting if the brush exist on Mac/Windows environment.

关于如何使用Javascript的任何提示? (JSX)

Any tips about how do this using Javascript? (JSX)

推荐答案

您可以使用此AM代码片段获取画笔或工具预设的列表.请注意,多个笔刷预设可能具有相同的名称.

You can get lists of brush or tool presets using this AM snippet. Note that several Brush Presets could have the same name.

var brushesList = getPresetList(0);
var brushName = 'Preset_55890'

for (var i = 0; i < brushesList.length; i++)
{
  if (brushesList[i] == brushName)
  {
    alert('found');
    break;
  }
}

// presetIndex: 0 to 7
// 0: Brush Presets
// 7: Tool presets

function getPresetList(presetIndex)
{
  var presetNames = [];
  var ref = new ActionReference();
  ref.putProperty(stringIDToTypeID("property"), stringIDToTypeID("presetManager"));
  ref.putEnumerated(stringIDToTypeID("application"), stringIDToTypeID("ordinal"), stringIDToTypeID("targetEnum"));
  var desc = executeActionGet(ref);
  var list = desc.getList(stringIDToTypeID("presetManager"));
  var nameList = list.getObjectValue(presetIndex).getList(stringIDToTypeID("name"));
  for (var nameIndex = 0; nameIndex < nameList.count; nameIndex++)
  {
    presetNames.push(nameList.getString(nameIndex));
  }
  return presetNames;
};

这篇关于如何检查Photoshop Brush是否以编程方式存在的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆