Skip to main content
1-Visitor
February 17, 2017
Solved

Play specific step of PVI sequence at studio

  • February 17, 2017
  • 1 reply
  • 8937 views

Hello all, I'm new here.

I'd like to know if there is a Javascript way to play specific step of PVI sequence at studio?

The following line works to play all steps of animation.

$scope.app.params.sequenceURL = "app/resources/Uploades/<name of PVI file>";

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

Instead, I'd like to play only step 2 using JS. Inside this PVI sequence, there is 3 steps.

Thanks in advanced!

Ewerton Moreira

Best answer by RolandRaytchev

So tested it and  you right! It does not play for example when I use some other step ... let say step 4.

So tested it some time and  modified and now is working with the followig script:

///////////////
$scope.sequence2 = function () {

//$scope.view.wdg['model-1']['sequence'] = 'app/resources/Uploaded/l-Creo 3D - TestFigure1.pvi';
//reset it only if you want to interrupt a playing step otherwise is not necessarily

$scope.$applyAsync(()=>{angular.element(document.getElementById('model-1')).scope().reset();}); //does not work synchronously //$scope.view.wdg['model-1']['currentStep']=4;
//delay of .5 sec to be sure that all action are done $timeout(function () { $scope.$applyAsync(()=>{$scope.setWidgetProp('model-1', 'currentStep', 4);}); //further delay for a 0.5 sec to be sure that the step is set and then play $timeout(function () {$scope.$root.$broadcast('app.view["Home"].wdg["model-1"].svc.play'); }, 500); }, 500); };

So hope now it will work also on your side! Thanks!

1 reply

1-Visitor
February 20, 2017

Hi Kelson,

There is a specific property for the current step in an animation. you should be able to call it as $scope.view.wdg['model-1']['currentStep']

Then, you can set that equal to 2 if you want to play step 2. After that, you should be able to start playing the animation as you would normally, and it should start on that step, but I'm not 100% certain as I haven't tried it myself.

5-Regular Member
June 5, 2018

It doesn't worked for me. Has anyone tried this?

 

I tried this:

 

$scope.sequence2 = function () {

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

  $timeout(function () {

    $scope.view.wdg['model-1']['currentStep']=1;

    $scope.$root.$broadcast('app.view["Home"].wdg["model-1"].svc.play');

  }, 500);

}

 

But it doesn’t play just the step 1 or 2 every time I call the service.

21-Topaz I
June 6, 2018

So tested it and  you right! It does not play for example when I use some other step ... let say step 4.

So tested it some time and  modified and now is working with the followig script:

///////////////
$scope.sequence2 = function () {

//$scope.view.wdg['model-1']['sequence'] = 'app/resources/Uploaded/l-Creo 3D - TestFigure1.pvi';
//reset it only if you want to interrupt a playing step otherwise is not necessarily

$scope.$applyAsync(()=>{angular.element(document.getElementById('model-1')).scope().reset();}); //does not work synchronously //$scope.view.wdg['model-1']['currentStep']=4;
//delay of .5 sec to be sure that all action are done $timeout(function () { $scope.$applyAsync(()=>{$scope.setWidgetProp('model-1', 'currentStep', 4);}); //further delay for a 0.5 sec to be sure that the step is set and then play $timeout(function () {$scope.$root.$broadcast('app.view["Home"].wdg["model-1"].svc.play'); }, 500); }, 500); };

So hope now it will work also on your side! Thanks!