setSelectedLevel gives an Error

This topic has been viewed 1220 times and has 2 replies
Thread status: Active
How can I do this? [img]http://www.sweethome3d.com/images/flags/en_small.gif[/img]
Post Reply New Topic
PacWood
Posts: 8
Joined: Tue Mar 13, 2018 9:43 am
Country: USA

setSelectedLevel gives an Error

Post by PacWood »

Hello,

I am attempting to select a level in a building via the API.

Below is a snippet of code that successfully runs until
the last line is reached.

Code: Select all

         var HOME;
	 var HPC =  viewHome("viewerCanvas",   
           homeUrl,          
           onerror,           
           onprogression,    
          { roundsPerMinute: 0,                
            navigationPanel: "default",                                           
            levelsAndCamerasListId: "levelsAndCameras",         
            selectableLevels: ["Level 1", "Level 2"],     
            activateCameraSwitchKey: true                      
          });

       HOME = HPC.getHome();

       var theLevels = HOME.getLevels();
       var levelName = theLevels[0].getName();
       console.log('levelName: '+levelName);
       var objLevel = theLevels[0];
       console.log(objLevel);
       HOME.setSelectedLevel("Level 1", objLevel);


At the line:

Code: Select all

      HOME.setSelectedLevel("Level 1", objLevel);


A javascript error occurs, which is:

Code: Select all

      "Error: TypeError: m.getElevation is not a function"


However, the code prints the object 'objLevel'

Code: Select all

 
       console.log(objLevel);


I can see in the console log, the object 'objLevel' shows
there is a function named "getElevation".

Does anyone have an idea why there is an error of
"getElevation is not a function"
and yet there is a function named "getElevation" in the object
that is being passed to HOME.setSelectedLevel() ?

Below is a screen shot of the console output.


Image


thank you for your help.
User avatar
Puybaret
Posts: 9440
Joined: Mon Nov 07, 2005 12:00 pm
Country: Paris, France
Contact:

Re: setSelectedLevel gives an Error

Post by Puybaret »

Sorry, the JSDoc of setSelectedLevel isn't clear and will be fixed in the next version.
[font=courier new]setSelectedLevel[/font] takes only one parameter:

Code: Select all

HOME.setSelectedLevel(objLevel);
Emmanuel Puybaret, Sweet Home 3D creator
PacWood
Posts: 8
Joined: Tue Mar 13, 2018 9:43 am
Country: USA

Re: setSelectedLevel gives an Error

Post by PacWood »

Thank you very much for your help and example code.

The program works now.
Post Reply New Topic

Who is online

Users browsing this forum: No registered users and 2 guests