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

Community Tip - Help us improve the PTC Community by taking this short Community Survey! X

Play two sequence by two different Buttons

DenGrz
8-Gravel

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.

ACCEPTED SOLUTION

Accepted Solutions
WilsonT
13-Aquamarine
(To:DenGrz)

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.

 

View solution in original post

2 REPLIES 2
WilsonT
13-Aquamarine
(To:DenGrz)

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.

 

DenGrz
8-Gravel
(To:WilsonT)

Hello @WilsonT ,

 

sorry for the last reply.

I test the code and works now perfect.

 

Thanks a lot.

Announcements

Top Tags