FORUMS: list search recent posts

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

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Paulo Jan
Scripting: strange behaviour when accesing filters in clips in FCP XML
on Oct 12, 2015 at 5:50:14 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?


Return to posts index

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
© 2018 CreativeCOW.net All Rights Reserved
[TOP]