Photoshop + JavaScript,为什么 docRef.selection.selectEllipse()、.selectColumn()、.selectPolygon()、.selectRectangle()、.selectRow() 不起作用?

问题描述 投票:0回答:1

我使用 JavaScript 自动化 Photoshop,这是我的代码:

var originalRulerUnits = app.preferences.rulerUnits
originalRulerUnits = Units.PIXELS

displayDialogs = DialogModes.NO

var fileRef = new File( "C:\\Users\\...\\Desktop\\...\\...\\test.png" );
app.open( fileRef );
var docRef = app.activeDocument;

所以这段代码工作正常,但接下来当我尝试时

docRef.selection.selectEllipse(
    {top: 50, left: 70, bottom: 140, right: 100},
    constants.SelectionType.EXTEND
);

docRef.selection.selectColumn(90);

有或没有await关键字,或者

docRef.selectEllipse({top: 0, left: 0, bottom: 100, right: 100});

等等,什么也没发生?

我在 Adobe 文档中找到了这些方法:
https://developer.adobe.com/photoshop/uxp/2022/ps_reference/classes/selection/#selectall

但它们不存在于 photoshop-javascript-ref-2020.pdf 中,也不存在于 photoshop-scripting-guide-2020.pdf 中( https://github.com/Adobe-CEP/CEP-Resources/tree/master /文档/产品%20special%20文档/Photoshop%20Scripting )

我使用的是 Photoshop 25.0.0,但这些工具(-椭圆选框工具;-单列选框工具;-多边形套索工具;-矩形选框工具)在 Photoshop 中已经使用了很多年,例如 .select( )

var shapeRef = [ [x2, y2], [width, y2], [width, height], [x2, height] ];
docRef.selection.select(shapeRef);

.selectAll()
效果很好。

那么我做错了什么?

javascript automation photoshop
1个回答
0
投票

所以,我在 Adobe 论坛上发布了同样的问题: https://community.adobe.com/t5/photoshop-ecosystem-discussions/javascript-why-methods-selectellipse-selectcolumn-selectpolygon-and-etc-don-t-work/m-p/14718959#M818766

并收到以下答案:这些方法仅适用于新的 UXP/BatchPlay 代码 (.psjs),而 ExtendScript/Action Manager 代码 (.jsx) 是遗留的,并且在其中,我的问题中讨论的这些方法在那里不起作用是。 “这些方法可以在 UXP 参考中找到,而不是在 Javascript 参考中找到。”

© www.soinside.com 2019 - 2024. All rights reserved.