Get current variant in a Web interface

Get current variant in a Web interface

hobbotuk
Contributor Contributor
691 Views
3 Replies
Message 1 of 4

Get current variant in a Web interface

hobbotuk
Contributor
Contributor

Hi,

 

We are doing some inteface, and we would like to get and show the name of the current variant, for example using

 

 te return of the getNodeVariantCurrent()  function

 

we have tried with

http://localhost:8888/pythoneval?value=getNodeVariantCurrent()

 

but we get a webpage, not a simplre string.

 

we also tried in the HTML with

 

<script>

Icon_Click = function() {

var i = document.createElement("img");

i.src="http://localhost:8888/variants?value=getNodeVariantCurrent('Name of the Variant')";

};

</script>

 

But it doesnt work

 

We are lost, and dont know what esle to try, any help?

 

Thanks in advence!

0 Likes
Accepted solutions (2)
692 Views
3 Replies
Replies (3)
Message 2 of 4

sinje_thiedemann
Autodesk
Autodesk
Accepted solution

Hi,
if you use the html page inside VRED through Media Editor, or Sceneplate Editor, you have access to a special java script object called vred, that has a method "executePythonCommand" to execute Python methods in VRED and get the return value:

function myFunction() {
   vred.executePythonCommand("getNodeVariantCurrent('Environments')", function(value)
   { 
      // do something with the value returned 
      alert(value); 
   });
}

 Please note, this will not work if you open the html page in a browser outside VRED.

For that, you need to do an HTML GET request with the pythoneval url. See this post: https://forums.autodesk.com/t5/vred-forum/html-5-support-in-media-editor-vred-demo-scene/m-p/7444019...

 

Kind regards

Sinje

Message 3 of 4

seiferp
Community Manager
Community Manager
Accepted solution

I´ve attached a simple example.

HTML.png

Message 4 of 4

hobbotuk
Contributor
Contributor

Crazy!!!

 

This is exactly what aI was lookinf for!!

 

Thank you sow much to both of you!