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

Play specific step of PVI sequence at studio

SOLVED
Highlighted
Level 1

Play specific step of PVI sequence at studio

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

1 ACCEPTED SOLUTION

Accepted Solutions

Re: Play specific step of PVI sequence at studio

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!

6 REPLIES

Re: Play specific step of PVI sequence at studio

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.

Re: Play specific step of PVI sequence at studio

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.

Re: Play specific step of PVI sequence at studio

Hello, 

I think your code is working fine but there are 2 things to change.

1.)(consider this point only if you do not did it already)  upload the pvi file form the pvz to the upload folder - (copy name.pvz to any_name.zip and upload  the file l-Creo 3D - Figure2.pvi to the upload folder )

2.) use instead of 'Uploaded/l-Creo 3D - Figure2.pvi'  this one 'app/resources/Uploaded/l-Creo 3D - Figure2.pvi'

 

So I tested your script in a project :

///////////////
$scope.sequence2 = function () {
$scope.view.wdg['model-1']['sequence'] = 'app/resources/Uploaded/l-Creo 3D - TestFigure1.pvi';
  $timeout(function () {
    $scope.view.wdg['model-1']['currentStep']=2;

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

An it was working fine, The step 2 of the sequnece was started.

2018-06-05_18-22-32.jpg

 

So step 2 of sequnece "TestFugure1.pvi" was started

2018-06-05_18-33-55.jpg

Re: Play specific step of PVI sequence at studio

Still doesn't play the right step animation. It should play every time the same step when I click play, right? It does not do that.

Re: Play specific step of PVI sequence at studio

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!

Re: Play specific step of PVI sequence at studio

Thank you very much, it worked just perfect. It was the incompatibility with syncronous.