Skip to main content
1-Visitor
Jan 24, 2020 11:11 AM UTC
Solved

Switching between sequence using buttons in vuforia studio

My pvz file of model contains two sequences. I want to place 2 buttons on 2D canvas which will choose which sequence to play. For example button-1 should play 'sequence-1' and button-2 should play 'sequence-2'.

 

Any suggestion would be appreciated.

vivekseAnswer
1-Visitor
Feb 4, 2020 5:36 AM UTC

Hi @potatochips 

Actually I didn't understand your query. As far as my query is concerned i used the following code to solve the problem-

 

$scope.sequence2 = function () {

$scope.view.wdg['model-1']['sequence'] = 'app/resources/Uploaded/l-Creo 3D - 2.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']=2;
//delay of .5 sec to be sure that all action are done
$timeout(function () {
$scope.$applyAsync(()=>{$scope.setWidgetProp('model-1', 'currentStep', 2);});
//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);

};

 

 

Hope this helps..

5 replies

17-Peridot
Jan 27, 2020 8:50 AM UTC

Hello Vivekse,

 

I think that the best is to have a custom javascript function who runs the sequence.

 

  1. Use a similar code in the javascript :
$scope.playSequence = function (sequence_file, time) {
 $scope.setWidgetProp('myModel', 'sequence', sequence_file);
 $scope.playMyAnimation(time);
}

$scope.playMyAnimation = function (timer) {
 $scope.$applyAsync();
 $timeout(function() {
 $scope.$boradcast('app.view["model"].svc.playAll')
 }, timer);
]

     2. In buttons, in Click event, click js button

     3. In button A, add this javascript code :

 

playSequence('MySequenceName', '4000');

      Where MySequenceName is a value similar to this format : MySequenceName.pvi.

      It is a filename with extension .pvi who can be found in pvz file exported from Creo Illustrate.

      A pvz file can be opened in zip archive editor to look inside it!

      4000 is the time in millisecond of the duration of the Sequence.

     4. Repeat the same step as at step 3 but change the parameters given to the function playSequence 

 

Best regards,

Samuel

Translate
1-Visitor
Jan 30, 2020 2:55 AM UTC

hi, i have a question.

Capture1.PNG

in the sequence tab, what should I put there? 

Translate
vivekse1-VisitorAuthorAnswer
1-Visitor
Feb 4, 2020 5:36 AM UTC

Hi @potatochips 

Actually I didn't understand your query. As far as my query is concerned i used the following code to solve the problem-

 

$scope.sequence2 = function () {

$scope.view.wdg['model-1']['sequence'] = 'app/resources/Uploaded/l-Creo 3D - 2.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']=2;
//delay of .5 sec to be sure that all action are done
$timeout(function () {
$scope.$applyAsync(()=>{$scope.setWidgetProp('model-1', 'currentStep', 2);});
//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);

};

 

 

Hope this helps..

Translate
1-Visitor
Jan 27, 2020 11:05 AM UTC

If u want swiching steps with the help of different buttons try to use this method.

 

https://community.ptc.com/t5/Vuforia-Studio/Creating-Buttons-For-Each-Step/m-p/645641 

Translate