Viewpoint Forums
Viewpoint Forums
JavaScript
Javascript and VETScript data exchange|
Go
![]() |
New
![]() |
Find
![]() |
Notify
![]() |
Tools
![]() |
Reply
![]() |
|
|
Junior Member |
Hello,
we bought an Enliven Pro Licence and we are currently testing data exchange between Javascript (HTML) and VETScript (mtx). We have not yet found a possibility to pass parameters from Javascript to VETScript. Reviewing the documentation didn’t help. We want to apply interactive changes to a model (size, textures) using HTML-controls. Until now, we could accomplish this only by creating VETScript dynamically from Javascript. This is somewhat cumbersome. Please find attached a simple example of our efforts. Could you give us a hint how to pass user input e.g. input text/html to VETScript? Thank you in advance. This message has been edited. Last edited by: MrBool, cube.zip (8 KB, 27 downloads) |
||
|
|
Member |
There is a VETScript keyword you can pass to the Execute method of the plugin:
vmp.Execute(‘VETScript( script )’); Basically, whatever you pass as the script gets evaluated in VETScript, like eval in javascript, so it’s all a string, but you can do stuff like this: vmp.Execute(‘VETScript(myFunc(‘+arg+’);’); or perhaps more accurately: vmp.Execute(‘VETScript(myFunc(“‘+arg+’”);’); |
|||
|
|
Junior Member |
Thank you for your quick response!
Could you please provide an example, how to define 'myFunc' and parameter handling in mtx? Below the code we tried for dynamically creating VETScript from Javascript. Thank you in advance. --- HTML <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <html> <head> <script language="javascript" src="MTS3Interface.js"></script> <script language="javascript"> <!-- var vmp; //This global variable is for the VET content function postevent(name, param) { vmp.PostEvent(name,param); } function Resize() { var value = document.getElementById('size').value; if (value !='') { vmp.ExecuteVETScript("MTSInstances.Cube.Scale.x="+value+";"); } } //--> </script> </head> <body> <script language="javascript"> vmp = new MTSPlugin("cube.mtx", 400, 400, "", "simple",''); </script> <form> <input type="text" name="size" /> <input type="button" name="CubeResize" value="Resize" onclick="javascript:Resize();"/> <!--input type="button" name="CubeResize" value="Resize" onclick="javascript </form> </body> </html> --- MTX <?xml version="1.0"?> <MTSScene Version="330" > <MTSSceneParms RenderMode="LightTexture" BlendShadow="1" EdgeBias="1" SortRule="0" ActiveCamera="MtsRuntimeCamera" /> <MTSCamera Name="MtsRuntimeCamera" CameraRotateMin="-10000.000187 -10000.000187 -10000.000187" CameraRotateMax="10000.000187 10000.000187 10000.000187" CameraScaleMin="0.01 0.01 0.01" CameraScaleMax="1000 1000 1000" OrbitDist="5" > <Rotate x="30" y="-332" z="0" /> <Pivot x="0" y="0.55573" z="0" /> <ViewLocation x="0" y="0" z="4" /> </MTSCamera> <MTSInstance Name="Cube" > <MTSGeometry Name="MTSSimple_0" MultiUV="0" Type="MTSCube"/> </MTSInstance> <MTSTimeElem Type="VETScriptInterpreter"/> <MTSAction Type="VETScript" Name="CubeResize"> <!-- //MTSInstances.Cube.Scale.x=3; --> </MTSAction> <MTSInteractor> <MTSHandle Event="CubeResize" Action="CubeResize" /> </MTSInteractor> </MTSScene> |
|||
|
|
Junior Member |
Anybody is still alive here?
|
|||
|
|
EnIgMaTiCScOrPioN Member |
Hi !!
Do you want your VET script inside the HTML code and not inside the MTX? If yes, your HTML script looks good. Just that you need no VET script written inside the MTX file. You just need the VETScriptListner. I modified your code and the modified files are attached. Hope this helps. Cheers, Anup cube_mod.zip (8 KB, 53 downloads) |
|||
|
| Powered by Eve Community |
| Please Wait. Your request is being processed... |
|
Viewpoint Forums
Viewpoint Forums
JavaScript
Javascript and VETScript data exchange
