cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Did you get called away in the middle of writing a post? Don't worry you can find your unfinished post later in the Drafts section of your profile page. X

How to play all the Sequences (.pvi), one by one on a single click of a button?

smishra-31
12-Amethyst

How to play all the Sequences (.pvi), one by one on a single click of a button?

Hi,

I have 5 sequences (5 .pvi files inside my .pvz file) and I want to play all of them one by one on a single click of a button. (Button should remain disabled till all the 5 sequences get completed.)

Next sequence should only be get start after completion of previous sequence. Like an assembly of a some figure/object.

What I have tried so far is (Not working currently):


var modelEle1 = angular.element(document.getElementById('model-1'));


$scope.sequence1 = function() {

     $scope.view.wdg['model-1']['sequence'] = 'l-Creo 3D Sequence1';

     $timeout(function() {modelEle1.scope().playAll();},600);

}

$scope.sequence2 = function() {

     $scope.view.wdg['model-1']['sequence'] = 'l-Creo 3D Sequence2';

     $timeout(function() {modelEle1.scope().playAll();},600);

     //$scope.view.wdg['model-1']['playAll'] = true;  Not working and is it a correct way to call it?

     //$scope.view.wdg['button-2']['click'] = true; Not working and is it a correct way to call it?

     //I have binded the "button-2" click event with "model-1" playAll service.

}

// I am calling this function on a button-1's click JS Box.

$scope.sequence = function() {

     $scope.sequence1();

     $scope.sequence2();

}

If there is any other efficient code/method to achieve this functionality, please provide it.

Thank you,

Shashank

ACCEPTED SOLUTION

Accepted Solutions

Hi,

In reply to my own question, I have done some changes in my code and now I have achieved the functionality, to some extent that I wanted (working fine in ThingWorx Preview mode but not looks good in ThingWorx View App). Still needs your suggestions to how to remove vibrations/shaking of model in ThingWorx "View" App.

Changed Code:

// I am setting the "Sequence1" to the "model-1" on button JS Box before calling the sequence() function.

$scope.sequence1 = function() {

    angular.element(document.getElementById('model-1')).scope().playAll();

}

$scope.sequence2 = function() {

    setTimeout(function() {

          $scope.$apply(function() {

                    $scope.view.wdg['model-1'].sequence = "Uploaded/l-Creo 3D - Sequence2.pvi";

                    angular.element(document.getElementById('model-1')).scope().playAll();

          });

    }, 6000); // My First Sequence is taking approax. 5 secs to execute. Extra 1 sec to just play safe.

}

$scope.sequence3 = function() {

    setTimeout(function() {

          $scope.$apply(function() {

                    $scope.view.wdg['model-1'].sequence = "Uploaded/l-Creo 3D - Sequence3.pvi";

                    angular.element(document.getElementById('model-1')).scope().playAll();

          });

    }, 10000); // This is the approax total time taken by Sequence1 & Sequence2. My Second Sequence is taking approax 3.5 sec to execute.

}

//I am calling this function on Button's JS Box on whose click the sequence need to be played by one-by-one.

$scope.sequence = function() {

    $scope.sequence1();

    $scope.sequence2();

    $scope.sequence3();

}

The JS code that I have written on Button's JS Box is:

setWidgetProp( 'model-1', 'sequence', 'l-Creo 3D - Sequence1.pvi');

sequence();

Some Key points to remember if you are using this code:

  1. Your ".pvi" file should be uploaded separately i.e they should be present in "Uploaded" folder. It won't work for ".pvi" files that present inside your ".pvz" file. So you have to first extract your ".pvi" file from your ".pvz" file than you have to upload it.
  2. setTimeout() function last parameter is in milliseconds and you have to calculate/observe manually how much previous sequence/sequences is taking time to execute.

Thank you,

Shashank

View solution in original post

3 REPLIES 3

Hi,

In reply to my own question, I have done some changes in my code and now I have achieved the functionality, to some extent that I wanted (working fine in ThingWorx Preview mode but not looks good in ThingWorx View App). Still needs your suggestions to how to remove vibrations/shaking of model in ThingWorx "View" App.

Changed Code:

// I am setting the "Sequence1" to the "model-1" on button JS Box before calling the sequence() function.

$scope.sequence1 = function() {

    angular.element(document.getElementById('model-1')).scope().playAll();

}

$scope.sequence2 = function() {

    setTimeout(function() {

          $scope.$apply(function() {

                    $scope.view.wdg['model-1'].sequence = "Uploaded/l-Creo 3D - Sequence2.pvi";

                    angular.element(document.getElementById('model-1')).scope().playAll();

          });

    }, 6000); // My First Sequence is taking approax. 5 secs to execute. Extra 1 sec to just play safe.

}

$scope.sequence3 = function() {

    setTimeout(function() {

          $scope.$apply(function() {

                    $scope.view.wdg['model-1'].sequence = "Uploaded/l-Creo 3D - Sequence3.pvi";

                    angular.element(document.getElementById('model-1')).scope().playAll();

          });

    }, 10000); // This is the approax total time taken by Sequence1 & Sequence2. My Second Sequence is taking approax 3.5 sec to execute.

}

//I am calling this function on Button's JS Box on whose click the sequence need to be played by one-by-one.

$scope.sequence = function() {

    $scope.sequence1();

    $scope.sequence2();

    $scope.sequence3();

}

The JS code that I have written on Button's JS Box is:

setWidgetProp( 'model-1', 'sequence', 'l-Creo 3D - Sequence1.pvi');

sequence();

Some Key points to remember if you are using this code:

  1. Your ".pvi" file should be uploaded separately i.e they should be present in "Uploaded" folder. It won't work for ".pvi" files that present inside your ".pvz" file. So you have to first extract your ".pvi" file from your ".pvz" file than you have to upload it.
  2. setTimeout() function last parameter is in milliseconds and you have to calculate/observe manually how much previous sequence/sequences is taking time to execute.

Thank you,

Shashank

Hi,

As I haven't received any reply on my post and I have achieved the functionality what I needed, I am marking my previous reply as a Correct Answer to this discussion.

Still any suggestion/answer from community side will always be welcome.. 

Thank you,

Shashank

Hi

Even I am trying to achieve the same. I have tried to do it on playstopped event but playstopped method is not getting triggered for every sequence. Please let me know if you have any idea on it.

 

Thanks

Announcements

Top Tags