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

Community Tip - When posting, your subject should be specific and summarize your question. Here are some additional tips on asking a great question. X

Get Length of Sequences

Wes_Tomer
12-Amethyst

Get Length of Sequences

Hello,

 

I know it is possible to get the length of the current sequence with $scope.app.view.Home.wdg["model"].steps however I would like to get the length of each sequence for the model, and store this in array.

 

Is there a way of getting each sequence length, other than creating a loop where I change the sequence and then get the steps each time?

 

For instance, if model-1 has

sequence 1: 10 steps,

sequence 2: 15 steps,

sequence 3: 7 steps

 

Is there a way to get this information without changing the current sequence multiple times?

In the end I will create an array [10,15,7]. This is useful for an overall progress bar I'm creating.

 

Thanks,

Wes

1 ACCEPTED SOLUTION

Accepted Solutions

Hi Roland,

 

Thank you for sharing this. I'm going to stick with this "hack" method of getting the sequence lengths while in Vuforia View. It only takes a fraction of a second, and it works:

 

//I loop through the pvi files with a recursive function until I’ve collected the number of steps from each:
//‘no’ or ‘yes’ denote whether or not there is an animation associated with that learning chapter.

var chapters = [['intro','no',2,'incomplete'], //_________________0
               ['tools','no',6,'incomplete'],  //_________________1
               ['components','no',3,'incomplete'],  //____________2
               ['Float_5FValve','yes',9,'incomplete'],  //________3
               ['Exhaust_5FFilters','yes',18,'incomplete'], //____4
               ['Antisuckback_5FValve','yes',9,'incomplete'] //___5
               ] // [0,1,2,3]

// Get chapter lengths *******************
var k=0;
var seqLenRequested = false;
getSequenceLengths = function(){
  seqLenRequested = true;
   if(chapters[k][1]=="yes"){
     $scope.setWidgetProp('pump', 'sequence', "app/resources/Uploaded/ASSEMBLY-without54/l-Creo 3D - "+chapters[k][0]+".pvi");  
     if(k+1<chapters.length){k++}
   }
   if(chapters[k][1]=="no"){
     if(k+1<chapters.length){
       k++;
       getSequenceLengths();
     }
   }
};

// event listener for sequence loaded
$scope.$on("sequenceloaded", function (evt, arg) {
  if(seqLenRequested){
  chapters[k][2]=$scope.app.view.Home.wdg.pump.steps;
    if(k<chapters.length){
    getSequenceLengths();
    }
  }
});

View solution in original post

4 REPLIES 4

Hi @Wes_Tomer ,

 

I don't think that currently we   have a method to get the info about all sequences with steps.

There is in generally 2 possible solutions.

1.) you can extract the data outside Studio using Creo View Toolkit tools as mention in the post "Extracting the viewables and the seqnece steps information from a .pvz file for the usage in TWX"[1]    

->Example for extracting of data : worldcar-brake-multi-figure.pvz

worldcar-brake-multi-figure.pvz-viewableSteplist.json

Here is a list of the steps of the vieable "Sequence" (viewable is Creo Illustrate Figure like a sequence , animation ...)

[{"viewablename":"Sequence","nr":0,"name":"Sequence","description":""},
{"viewablename":"Sequence","nr":1,"name":"Step 1","description":"Remove spring clips"},
{"viewablename":"Sequence","nr":2,"name":"Step 2","description":"Release 4 bolts"},
{"viewablename":"Sequence","nr":3,"name":"Step 3","description":"Pull apart the calipers"}]

worldcar-brake-multi-figure.pvz-viewablelist.json

Here is the list of all viewables - where some of them are Sequences. Currently only the sequences are visible in Vuforia View )

 

[{"name":"Figure 1","value":"Figure 1","type":"viewable","hasSequence":false,"hasAnimation":false},
{"name":"Sequence","value":"Sequence","type":"viewable","hasSequence":true,"hasAnimation":false},
{"name":"Parts List","value":"Parts List","type":"viewable","hasSequence":false,"hasAnimation":false},
{"name":"Sectioning","value":"Sectioning","type":"viewable","hasSequence":false,"hasAnimation":false},
{"name":"Translation","value":"Translation","type":"viewable","hasSequence":false,"hasAnimation":false},
{"name":"Animation","value":"Animation","type":"viewable","hasSequence":false,"hasAnimation":true}]

 

As further demonstrated in the post [1] we can load the data as json object to Thingworx repository and use it as in a TWX service to access the data from Vuforia Studio.

 

2.) Another option (as you already supposed in your post)  is to start in JavaScript a loop where we will set the  current sequence to each item in the  Sequence List model widget property  and check the Steps property. 

This could be started only one time - in preview and saved to twx for later usage. Or it is possible to do this every time when we received the experience first time ... also in view but this could lead to some delay and flickering on start .

I did not test this approach by me self but I think it should work.  If you have some difficulties to implement this , then please, let me know, so I will test it.

Hi Roland,

 

Thank you for sharing this. I'm going to stick with this "hack" method of getting the sequence lengths while in Vuforia View. It only takes a fraction of a second, and it works:

 

//I loop through the pvi files with a recursive function until I’ve collected the number of steps from each:
//‘no’ or ‘yes’ denote whether or not there is an animation associated with that learning chapter.

var chapters = [['intro','no',2,'incomplete'], //_________________0
               ['tools','no',6,'incomplete'],  //_________________1
               ['components','no',3,'incomplete'],  //____________2
               ['Float_5FValve','yes',9,'incomplete'],  //________3
               ['Exhaust_5FFilters','yes',18,'incomplete'], //____4
               ['Antisuckback_5FValve','yes',9,'incomplete'] //___5
               ] // [0,1,2,3]

// Get chapter lengths *******************
var k=0;
var seqLenRequested = false;
getSequenceLengths = function(){
  seqLenRequested = true;
   if(chapters[k][1]=="yes"){
     $scope.setWidgetProp('pump', 'sequence', "app/resources/Uploaded/ASSEMBLY-without54/l-Creo 3D - "+chapters[k][0]+".pvi");  
     if(k+1<chapters.length){k++}
   }
   if(chapters[k][1]=="no"){
     if(k+1<chapters.length){
       k++;
       getSequenceLengths();
     }
   }
};

// event listener for sequence loaded
$scope.$on("sequenceloaded", function (evt, arg) {
  if(seqLenRequested){
  chapters[k][2]=$scope.app.view.Home.wdg.pump.steps;
    if(k<chapters.length){
    getSequenceLengths();
    }
  }
});

Of course, this overwrites each chapter length, so you can put anything you want in chapters[i][2]

The data can be used later to calculate the overall percentage complete.

 

var chapters = [['intro','no',2,'incomplete'], //_________________0

               ['tools','no',6,'incomplete'],  //_________________1

               ['components','no',3,'incomplete'],  //____________2

               ['Float_5FValve','yes',9,'incomplete'],  //________3

               ['Exhaust_5FFilters','yes',18,'incomplete'], //____4

               ['Antisuckback_5FValve','yes',9,'incomplete'] //___5

               ] // [0,1,2,3]

 

 

It would also be possible to get the list of sequences with another function:

 

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

Top Tags