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 +クリック」をプログラムで実行する方法はありますか?私は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 に答える