Community
VRED Forum
Welcome to Autodesk’s VRED Forums. Share your knowledge, ask questions, and explore popular VRED topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Tutorials using the command sendToWebEngine are missing a vital detail

3 REPLIES 3
Reply
Message 1 of 4
Anonymous
506 Views, 3 Replies

Tutorials using the command sendToWebEngine are missing a vital detail

There are a lot of great samples how to use HTML5 with VRED.

 

Unfortunately none of them shows how to access the data parameter of the following python code in JavaScript

sendToWebEngine( name, event, data )

VRED uses a so called CustomEvent to talk to the WebEngine. I was successfully accessing the data parameter from python as the .detail member of the JavaScript event like this:

  document.addEventListener("SET_TEXT1", function(evt) {
    document.getElementById("hudText1").innerText = evt.detail;
  });
3 REPLIES 3
Message 2 of 4
Anonymous
in reply to: Anonymous

Hello, I'm trying to display the data parameter on my browser.

I tried this but it did not work.

	sendToWebEngine("SizeValue", "ValueX", str(XValue))
<!DOCTYPE html>
<html>
<head>
    <title></title>
</head>
<body>
    <h1>SIZE</h1>
    <script>
    document.addEventListener("ValueX", function(evt) {
            ValueX= document.getElementById("XValue").innerText = evt.detail;
            });
            
         document.write(ValueX);
    </script> 

</body>
</html>
Message 3 of 4
Anonymous
in reply to: Anonymous

Dear Ayoub, 

 

your attempt is wrong in many levels. Let me try to both give you running code for your use case and also explain how it works.

 

Python side needs to look like this:

 

 

 

sendToWebEngine(nameOfEngine, "SET_SIZE", "x="+str(xSize)+", y="+str(ySize))

 

 

 

 

HTML side should look like this:

 

 

 

<!DOCTYPE html>
<html>
<head>
    <title></title>
</head>
<body>
    <h1>SIZE</h1>
    <span id="sizeValue">to be replaced by event listener</span>
    <script>
    document.addEventListener("SET_SIZE", function(evt) {
       document.getElementById("sizeValue").innerText = evt.detail;
    });
    </script> 
</body>
</html>

 

 

 

Message 4 of 4
Anonymous
in reply to: Anonymous

Hello, thank you for the answer.

 

 

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report