How to add a specific xml element ?

  • Ok thank you, that helps me :)  
    But i have an issue with


    set(connection[get(h)].hdir,"hdir");

    I want to make a script so that every scene will automatically be like that :


    So i have to create
    1. a layer named "connections"
    2.as much connection element as hotspot numbers.
    3. set the connection element name and hdir
    4. set connection elements parent to layer connections


    Code
    for(set(h,0), h LT hotspot.count, inc(h);,      def(connection, array);                set(connection[get(h)].name,"name"); 
         set(connection[get(h)].hdir,"hdir");
         trace(connection[get(h)].name);
         trace(connection[get(h)].hdir); 
         debugvar(connection););


    for the first hotspot, it traces me :

    Code
    INFO: connection[get(h)].name 
    INFO: connection[get(h)].hdir 
    DEBUG: connection=[[object Object]] length=1 type=array


    But my issue is that

    Code
    set(connection[get(h)].name,"name");

    doesn't seems to work properly because it should trace me "name" if it has worked...


    Am I not using set(connection[get(h)].name,"name"); wright ?

    Hope i'm clear ;)

    Thanks a lot !

    Matthias

    Edited once, last by m.conche (December 11, 2020 at 12:55 PM).

  • hm not sure if you can set the name using an index ....
    also you cant set multiple array items with the same name

    maybe its better to use directly the name like this:

    Code
    def(connection, array); // JUST ONCE!
    for(set(h, 0), h LT hotspot.count, inc(h),
         calc(myname, "myname_" + h);
         calc(myhdir, "myhdir_" + h);
         copy(connection[get(myname)].hdir, myhdir);
         debugvar(connection[get(myname)]);
    );
    debugvar(connection);

    or you use the hotspot name as direct reference

    Code
    def(connection, array); // JUST ONCE!
    for(set(h, 0), h LT hotspot.count, inc(h),
         copy(myname, hotspot[get(h)].name);
         calc(myhdir, "myhdir_" + h);
         copy(connection[get(myname)].hdir, myhdir);
         debugvar(connection[get(myname)]);
    );
    debugvar(connection);

    but i'm not getting at all what you're trying to do here *squint*
    connection is not a layer, its a krpano array
    what is the connections layer for? you dont need that for an array.
    (also i'm not 100% sure if you can create an array inside a layer.)
    what is hdir?
    and why not simply store your hdir info in the hotspot itself ?

    Code
    for(set(h, 0), h LT hotspot.count, inc(h),
         calc(myhdir, "myhdir_" + h);
         copy(hotspot[get(h)].hdir, myhdir);
         debugvar(hotspot[get(h)]);
    );
    debugvar(hotspot);
  • I've solved it !

    the problem was because of PARENT and CHILD problem !


    Code
    for(set(h,0), h LT hotspot.count, inc(h);, 
     def(connection, array); 
     set(connection[get(h)].parent,connections); 
     set(layer[connections].connection[get(h)].name,"name"); 
     set(layer[connections].connection[get(h)].hdir,"hdir");
    );

    Like that it works properly !

    thanks a lot for your help *smile*

  • I've solved it !

    the problem was because of PARENT and CHILD problem !


    Code
    for(set(h,0), h LT hotspot.count, inc(h);, 
    	def(connection, array); 
    	set(connection[get(h)].parent,connections); 
    	set(layer[connections].connection[get(h)].name,"name"); 
    	set(layer[connections].connection[get(h)].hdir,"hdir");
    );

    Like that it works properly !

    thanks a lot for your help *smile*

Participate now!

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