How to "Count" the children layer ?

  • <layer name="a">
    <layer name="b"></layer>
    <layer name="c"></layer>
    < layer name="d"></layer>
    </layer>

    <action name="countchild">
    for(set(i,0),i LT ??,inc(i), set(layer[get(i)].url,subtxt("image",get(i),".jpg"); )
    </action>


    ?? = 3
    layer[0] -> layer[a]
    layer[1] -> layer[b]
    layer[2] -> layer[code=c]

    Edited 3 times, last by iamroco (September 16, 2015 at 6:41 AM).

  • Code
    <layer name="a">
      <layer name="b"/>
      <layer name="c"/>
      <layer name="d"/>
    </layer>
    Code
    <action name="countchild">
    set(parent_a_counter,0);
    for(set(i,0),i LT layer.count,inc(i),	
      if(layer[get(i)].parent EQ 'a',
      inc(parent_a_counter);set(layer[get(i)].url,subtxt("image",get(get(i)),".jpg"););
      );
    );
    trace('Total numbner of children:',get(parent_a_counter));
    </action>
  • Taken from https://krpano.com/docu/actions/#arrays:

    Quote

    Every xml element with a name attribute is an element / item of an Array


    In this case surely layer[a], in the OP's example, should be an array?

    I would love to access layer[a].count and also a child object, using layer[a][0], but it doesn't seem to work.

    Please could someone clarify the situation and give me a pointer if it is just a problem with my syntax?

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!