You are not logged in.

Dear visitor, welcome to krpano.com Forum. If this is your first visit here, please read the Help. It explains in detail how this page works. To use all features of this page, you should consider registering. Please use the registration form, to register here or read more information about the registration process. If you are already registered, please login here.

Tuur

Sage

  • "Tuur" started this thread

Posts: 3,347

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*
http://www.virtualtuur.com
Skype:studiotuur

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


spacerywirtualne

Professional

Posts: 988

Location: Poland, Europe

Occupation: krpano developer : virtual tours

  • 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 online, cloud tool for creating virtual tours - www.cms4vr.com

facebook page :: youtube

cms4vr team *thumbsup*

Tuur

Sage

  • "Tuur" started this thread

Posts: 3,347

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*
http://www.virtualtuur.com
Skype:studiotuur

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,347

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*
http://www.virtualtuur.com
Skype:studiotuur