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

Community Tip - Need to share some code when posting a question or reply? Make sure to use the "Insert code sample" menu option. Learn more! X

how to change model sequence

CHASEONHO
18-Opal

how to change model sequence

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

ACCEPTED SOLUTION

Accepted Solutions

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

 

View solution in original post

2 REPLIES 2

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

 

Any Examble project is there for reference.

 

Announcements

Top Tags