0


我有这个脚本,它正在显示  View --> Show Structure  窗格:

with(obj.doc.xmlViewPreferences)
{
    // this opens the View --> Show Structure pane
    showStructure = true;

    showTagMarkers = true;
    showTaggedFrames = true;
    showTextSnippets = true;
}


但是,根节点保持最小化。我发现按住  Alt  键并单击此根节点展开整个树。

那么有没有办法在这个根节点上以编程方式执行“Alt + click”?我正在使用 Windows 和 CS5。

4

1 回答 1

1

您可以通过选择节点来接近。例如,选择第 3 层的所有元素,并在您将使用的所有层上扩展所有元素的过程中

app.select(
    app.activeDocument.xmlElements.item(0) // the root element
    .xmlElements.everyItem() // repeat this line for each nesting level
    .xmlElements.everyItem() // and so forth
    .getElements() // provide an array with the actual selectable items
);

重复指示线以获得更深层次。使用以下代码段,您还可以选择那些没有子元素的 XML 属性:

.xmlAttributes.everyItem()

最后取消选择以清理选择亮点。

app.select(null);

编辑:对于任意深度,您可以使用循环。在请求之前,它应该确保 XMLElement / XMLAttribute 集合中有元素。结果代码:

var items = app.activeDocument.xmlElements.everyItem();
while( items.xmlElements.length ) {
    items = items.xmlElements.everyItem();
    app.select(items.getElements());
    if( items.xmlAttributes.length )
        app.select(items.xmlAttributes.everyItem().getElements());
}
app.select(null);
于 2012-08-10T10:27:11.517 回答