You are not logged in.

Tuur

Sage

  • "Tuur" started this thread

Posts: 3,729

Location: Netherlands

Occupation: Krpano custom coding / Virtual Tours / Photography / Musician / Recording engineer

  • Send private message

1

Saturday, February 29th 2020, 2:25pm

copy all attributes as string

Hi Klaus,

i was wondering if it is, or could be made, possible to put all attributes AND their vallues, of a hotspot/layer, to a variable as a string. (in xml)
Except the name i suppose.
For example like:
<hotspot name="klaus" bgcolor="0xff0000" text="i love krpano" etc..
..
copy(tuur, get(hotspot[klaus].attributes));
or
calc(tuur, hotspot[klaus].attributes);

or so..
And that in the var the value is:
bgcolor="0xff0000" text="i love krpano" etc..

i can imagine issues with apostrophes etc..

Tuur *thumbsup*

This post has been edited 3 times, last edit by "Tuur" (Feb 29th 2020, 4:29pm)


spacerywirtualne

Professional

Posts: 1,102

Location: Poland, Europe

Occupation: krpano developer : virtual tours : the cms4vr owner

  • Send private message

2

Saturday, February 29th 2020, 5:21pm

Hi Tuur,

https://krpano.com/docu/actions/#copyattributes


Have you tried that?


Piotr
Your own professional, online cloud tool for creating virtual tours - www.cms4vr.com

facebook page :: youtube

cms4vr team *thumbsup*

Tuur

Sage

  • "Tuur" started this thread

Posts: 3,729

Location: Netherlands

Occupation: Krpano custom coding / Virtual Tours / Photography / Musician / Recording engineer

  • Send private message

3

Saturday, February 29th 2020, 5:53pm

yes quickly.. but i think it has another function.
Or i was wrong..
Tuur *thumbsup*

4

Monday, March 2nd 2020, 9:33am

Hi,

there is the getattributes() function that's available on each object (but callable only from JS):
https://krpano.com/docu/plugininterface/#getattributes

It will return an array with the names of all attributes from an object.

Here an example that logs all attributes and their value:

Source code

1
2
3
4
5
6
7
8
9
10
<action autorun="onstart" type="Javascript"><![CDATA[
    var layer = krpano.get("layer[ANY_NAME_OR_INDEX]");
    var attributes = layer.getattributes();
    for (var i=0; i < attributes.length; i++)
    {
        var attrib = attributes[i];
        var value = layer[attrib];
        console.log(attrib + "=" + value);
    }
]]></action>


But it would need to be used with care, there can be also state-attributes and internal attributes included there. And when simply copied them to another object, the real state of that object might be wrong (e.g. the loading state).

Best regards,
Klaus

Tuur

Sage

  • "Tuur" started this thread

Posts: 3,729

Location: Netherlands

Occupation: Krpano custom coding / Virtual Tours / Photography / Musician / Recording engineer

  • Send private message

5

Monday, March 2nd 2020, 9:49am

Hi,

thanks for the example.

mmm.. yes.. i know/understand (i think) ..let me think..
I asked this because i like to save, temporarily, all attributes to a temporary array to pick them up later.
Of course using style makes things easy. But not everybody does that always...

Tuur *thumbsup*

6

Monday, March 7th 2022, 10:45pm

debug variables

Hi guys!

Just in case you are interested in attributes which cannot get the .getattributes() (e.g. scene[0]) I use my debug vars function for krpano objects, arrays, ...

Source code

1
2
dv(layer[any])
dv(scene)
or to clear message log

Source code

1
dv


Source code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
<action name="dv" scope="local" args="dstring, " > 
if (dstring, 
debug('=================== ', %0,'(', dstring, ') ==================== tick=', calc(global.timertick BOR 0)); 
debugvar(get(dstring)); 
if (%1.count, 
for(set(i,0), i LT %1.count, inc(i), 
debug(' ----------------------- (', calc(i + '/' + (%1.count - 1)), ') ----------------------- ', calc(dstring + '[' + i + '].name'), ' -------'); 
debugvar(calc(dstring + '[' + i + ']')); 
); 
, 
); 
, 
trace([CLEARLOG]); 
); 
</action>


Enjoy,
Pavel