Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Scripting: strange behaviour when accesing filters in clips in FCP XML

  • Scripting: strange behaviour when accesing filters in clips in FCP XML

    Posted by Paulo Jan on October 12, 2015 at 5:50 pm

    Say I have the following Final Cut XML file, describing a sequence with clips in it:

    <clipitem id="clipitem-184" frameBlend="FALSE">
    <masterclipid>masterclip-67</masterclipid>
    <name>D02_C0101.MP4</name>
    <filter>
    <effect>
    <name>Opacity</name>
    <effectid>opacity</effectid>
    </effect>
    </filter>
    <filter>
    <effect>
    <name>Time Remap</name>
    <effectid>timeremap</effectid>
    </effect>
    </filter>
    </clipitem>
    <clipitem id="clipitem-185" frameBlend="FALSE">
    <masterclipid>masterclip-68</masterclipid>
    <name>D02_C0083.MP4</name>
    <filter>
    <effect>
    <name>Time Remap</name>
    <effectid>timeremap</effectid>
    </effect>
    </filter>
    </clipitem>

    As you can see, one of the clipitem elements has 2 filter descendants, while the other one only has one.

    I want to write a piece of Javascript/Extendscript to traverse through the XML and delete all the time remapping filters (that is, all the ones for which “effectid” is “timeremap”), but the problem is that Extendscript is returning me descendants at different levels, depending on whether there there’s just one filter element or more. For example, take this code:

    for each(sxClipDeSeq in sxClipsEnSeq) {
    for each (filtro in sxClipDeSeq.filter) {
    alert(filtro.toString());
    }
    }

    When this code accesses an element with just one filter, I get:

    <effect>
    ...
    </effect>

    Without the “filter” tag. but if I access an element with 2 filters, I get the proper tree as it appears on the XML:

    <filter>
    <effect>
    ...
    </effect>
    </filter>
    <filter>
    <effect>
    ...
    </effect>
    </filter>

    The same thing happens if I try to use the “descendants()” method from Extendscript. The docs say that it will return matching elements “at any level”, but if I try:

    for each(sxClipDeSeq in sxClipsEnSeq) {
    for each (filtro in sxClipDeSeq.filter) {
    var efecto=filtro.descendants("effect");
    alert(efecto.toString());
    }
    }

    In the first clip of the XML above, which has 2 filters, I get

    <effect>
    ...
    </effect>

    And in the second clip, which has only one filter, I get nothing.

    What’s going on? Why does this happen?

    Paulo Jan replied 8 years, 7 months ago 1 Member · 0 Replies
  • 0 Replies

Sorry, there were no replies found.

We use anonymous cookies to give you the best experience we can.
Our Privacy policy | GDPR Policy