Skip to main content
May 26, 2018 1:55 AM UTC
Question

thingworx studio model reset ??

 angular.element(document.getElementById('3DModel-2')).scope().reset();

 

why error??? 

 

The API function does not work.

 

 

 

 

3 replies

Jun 4, 2018 12:38 PM UTC

Hi,

 

I use in the javascript some code like this.

$scope.app.m1reset = function()
{ twx.app.fn.triggerWidgetService("model-1", 'reset');
$scope.$applyAsync(); };

as for me is working fine. May be you can try

Thanks!

 

 

Jun 4, 2018 2:10 PM UTC

I tested also the mention method but it work fine so believe there is some thing else wrong.

For example the name of the model is not correct ...etc. 

You can press Strg - Shift - I key to start the Chrome in debugging mode:

2018-06-04_15-56-31.jpg

So in the console you can see what of error occurred. So for example I clicked the playAll button before the preview was not already initialized and therefore the error.

Clicking the Reset button here will call the function Reset1() which is working fine. e.g.:

2018-06-04_15-56-54.jpg

So I used the following script code:

///////////////////////// used in button "playAll"
$scope.sequence1 = function() {
angular.element(document.getElementById('model-1')).scope().playAll();
 
};

////////////////////////// used in button _"Reset"
$scope.reset1 = function() {
angular.element(document.getElementById('model-1')).scope().reset(); 
};
Jun 4, 2018 5:56 PM UTC

another version what also should work for a model with name "model-1"  is this:

/////////
$scope.testReset= () =>{
var element = angular.element(document.querySelector('twx-widget[widget-id=\"model-1\"] twx-dt-model'));
element.scope().reset();
};