Skip to main content
1-Visitor
Apr 29, 2020 9:17 AM UTC
Solved

Play two sequence by two different Buttons

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.

WilsonTAnswer
14-Alexandrite
Apr 29, 2020 10:40 AM UTC

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.

 

2 replies

WilsonT14-AlexandriteAnswer
14-Alexandrite
Apr 29, 2020 10:40 AM UTC

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.

 

Translate
DenGrz1-VisitorAuthor
1-Visitor
May 6, 2020 11:35 AM UTC

Hello @WilsonT ,

 

sorry for the last reply.

I test the code and works now perfect.

 

Thanks a lot.

Translate