Skip to main content
18-Opal
April 17, 2018
Solved

how to change model sequence

  • April 17, 2018
  • 1 reply
  • 5156 views

Hi, i created a Three of sequence.

 

but ThingWorx studio can select one sequence

 

I want to change a sequence via button or list

 

how can i change sequence at running app

 

Thank you

Best answer by rperdigao

Hi,

Here is my suggestion:

  • Copy the .pvz file to .zip and extract it to find the .pvi file names inside of it.
  • Each .pvi name will represent one your 3 sequence. Write down the file names.
  • On Studio, click and edit the <<viewname>>.js file

Add the following JavaScript code:

$scope.FirstSequence = function() {
 $scope.view.wdg['model-1']['sequence'] = 'l-Creo%203D%20-%20Figure%201.pvi';
 $scope.$applyAsync();
 $timeout(function() {
 $scope.$broadcast('app.view["model-1"].svc.playAll')
 }, 400)
};
$scope.SecondSequence = function() {
 $scope.view.wdg['model-1']['sequence'] = 'l-Creo%203D%20-%20Figure%202.pvi';
 $scope.$applyAsync();
 $timeout(function() {
 $scope.$broadcast('app.view["model-1"].svc.playAll')
 }, 400)
};
$scope.ThirdSequence = function() {
 $scope.view.wdg['model-1']['sequence'] = 'l-Creo%203D%20-%20Figure%203.pvi';
 $scope.$applyAsync();
 $timeout(function() {
 $scope.$broadcast('app.view["model-1"].svc.playAll')
 }, 400)
};
  • Replace 'mode-1' with the name of your model
  • Replace the .pvi files names with your file names (initial steps). Spaces have to be replaced with %20
  • Save the JavaScript file
  • Go to the First Button and find "Click" under EVENTS
  • Click on the JS in front of the "Click" event and add the following:

 

FirstSequence();
  • Repeat the last 3 steps for the other 2 buttons and adjust the function name accordingly
  • The code above is changing the Sequence and Playing it.  If don't want to start the "playAll" action, remove or comment the following lines from the code:
     $timeout(function() {
     $scope.$broadcast('app.view["model-1"].svc.playAll')
     }, 400)

Best of luck,

Ricardo

 

1 reply

rperdigao5-Regular MemberAnswer
5-Regular Member
April 17, 2018

Hi,

Here is my suggestion:

  • Copy the .pvz file to .zip and extract it to find the .pvi file names inside of it.
  • Each .pvi name will represent one your 3 sequence. Write down the file names.
  • On Studio, click and edit the <<viewname>>.js file

Add the following JavaScript code:

$scope.FirstSequence = function() {
 $scope.view.wdg['model-1']['sequence'] = 'l-Creo%203D%20-%20Figure%201.pvi';
 $scope.$applyAsync();
 $timeout(function() {
 $scope.$broadcast('app.view["model-1"].svc.playAll')
 }, 400)
};
$scope.SecondSequence = function() {
 $scope.view.wdg['model-1']['sequence'] = 'l-Creo%203D%20-%20Figure%202.pvi';
 $scope.$applyAsync();
 $timeout(function() {
 $scope.$broadcast('app.view["model-1"].svc.playAll')
 }, 400)
};
$scope.ThirdSequence = function() {
 $scope.view.wdg['model-1']['sequence'] = 'l-Creo%203D%20-%20Figure%203.pvi';
 $scope.$applyAsync();
 $timeout(function() {
 $scope.$broadcast('app.view["model-1"].svc.playAll')
 }, 400)
};
  • Replace 'mode-1' with the name of your model
  • Replace the .pvi files names with your file names (initial steps). Spaces have to be replaced with %20
  • Save the JavaScript file
  • Go to the First Button and find "Click" under EVENTS
  • Click on the JS in front of the "Click" event and add the following:

 

FirstSequence();
  • Repeat the last 3 steps for the other 2 buttons and adjust the function name accordingly
  • The code above is changing the Sequence and Playing it.  If don't want to start the "playAll" action, remove or comment the following lines from the code:
     $timeout(function() {
     $scope.$broadcast('app.view["model-1"].svc.playAll')
     }, 400)

Best of luck,

Ricardo

 

13-Aquamarine
July 4, 2023

Any Examble project is there for reference.