Skip to main content
1-Visitor
April 29, 2020
Solved

Play two sequence by two different Buttons

  • April 29, 2020
  • 1 reply
  • 2420 views

Hello,

i create two sequences and i want to play the sequences by two different buttons.

I found a post there is similar to this topic, but it doesn´t work.

Does anyone has a demo project, where that is shown or can explain how it works?

 

Thanks in advance.

Best answer by WilsonT

Hi @DenGrz,

 

If I understand you correctly, do you mean that you have a single 3D model with two sequences created, and you would like to play each of them with different buttons?

 

If yes, you can achieve this with the following code. Do not assign any sequence to your model first and leave it as blank.

$scope.playSequence1 = function() {
 
 $scope.view.wdg['model-1']['sequence'] = '<sequence-1>.pvi';
 $scope.$applyAsync();
 
 $timeout(function() {
 $scope.$broadcast('app.view["model-1"].svc.playAll')
 }, 400)
}

$scope.playSequence2 = function() {
 
 $scope.view.wdg['model-1']['sequence'] = '<sequence-2>.pvi';
 $scope.$applyAsync();
 
 $timeout(function() {
 $scope.$broadcast('app.view["model-1"].svc.playAll')
 }, 400)
}

 

Replace <sequence-1>.pvi and <sequence-2>.pvi with your own sequences. Then, create two buttons to trigger the two functions (playSequence1() and playSequence2() ) respectively.

 

If you want to reset the model animation, you can remove its sequence with the following function.

$scope.resetSequence = function() {
 $scope.view.wdg['model-1']['sequence'] = '';
}

 

Hope this helps.

 

1 reply

WilsonT14-AlexandriteAnswer
14-Alexandrite
April 29, 2020

Hi @DenGrz,

 

If I understand you correctly, do you mean that you have a single 3D model with two sequences created, and you would like to play each of them with different buttons?

 

If yes, you can achieve this with the following code. Do not assign any sequence to your model first and leave it as blank.

$scope.playSequence1 = function() {
 
 $scope.view.wdg['model-1']['sequence'] = '<sequence-1>.pvi';
 $scope.$applyAsync();
 
 $timeout(function() {
 $scope.$broadcast('app.view["model-1"].svc.playAll')
 }, 400)
}

$scope.playSequence2 = function() {
 
 $scope.view.wdg['model-1']['sequence'] = '<sequence-2>.pvi';
 $scope.$applyAsync();
 
 $timeout(function() {
 $scope.$broadcast('app.view["model-1"].svc.playAll')
 }, 400)
}

 

Replace <sequence-1>.pvi and <sequence-2>.pvi with your own sequences. Then, create two buttons to trigger the two functions (playSequence1() and playSequence2() ) respectively.

 

If you want to reset the model animation, you can remove its sequence with the following function.

$scope.resetSequence = function() {
 $scope.view.wdg['model-1']['sequence'] = '';
}

 

Hope this helps.

 

DenGrz1-VisitorAuthor
1-Visitor
May 6, 2020

Hello @WilsonT ,

 

sorry for the last reply.

I test the code and works now perfect.

 

Thanks a lot.