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

Re: Model pvz sequence binding at runtime

SOLVED

Re: Model pvz sequence binding at runtime

So according to the subject here I want to add some points, which could be helpful, I hope.

- I suspect that the most stable sequences are generated with Creo Illustrate 3.0 and 3.1. Also 4.0 should work.

-When we want to use dynamic pvi  sequences in the HoloLens  we have to extract the .pvi file from the .pvz and upload the pvi sequences file  explicitly in the Studio resource folder. So here an example: 

example.png

So in the code below we will set the property of the sequence in the  modelload event (to ensure that the model is already loaded) and then  the code will execute the play of the first step with some timeout of 1 second. Loadsequnece method could also be called from any UI elements (button , change of slider ... etc.)

I think there is no problem to set different sequences at runtime with the method setWidgetProp and play them -but my experience is that it will work only in preview. On the HoloLens the animation will work only if the pvi file are xtracted from pvz and uploaded explicitly to the upload folder. Also, you have to pay attention that the sequence name is deferent (resource folder file name  and the  model property-> sequence)!

// $scope, $element, $attrs, $injector, $sce, $timeout, $http, $ionicPopup, and $ionicPopover services are available

$scope.app.loadsequence = function()
                { $scope.setWidgetProp('model-1', 'sequence', "app/resources/Uploaded/l-Creo 3D - Formgebung.pvi"); 
                  twx.app.fn.triggerWidgetService("model-1", 'play'); 
    }
///////
$rootScope.$on('modelLoaded', function()
               {$scope.app.loadsequence();
                console.warn("$scope.app.loadsequence() executed");                         
                                                               $timeout( function() {
                          $scope.app.loadsequence();
                          console.warn("app.loadsequence() executed");                           
                          $scope.$applyAsync();
                                     }, 1000);
                                          
                                          });
1 ACCEPTED SOLUTION

Accepted Solutions

Re: Model pvz sequence binding at runtime

Hi,

You need to go to the widget property through the $scope. You can find that your model widget has something called sequence property.

3.PNG

Sequences created in Creo software are saved in PVI format and it is a part of the PVZ model file. You can try to open PVZ file as an archive to see that it contains your sequences in separated PVI files.

So now you can try with two things:

1. Assign the sequence name directly to the property like this: $scope.view.wdg['model-1'].sequence = "mySecondSequence";

2. Try to assign it by path like it is shown above. (it can be painful to figure out correct path).

I didn't test it yet, so you can give me a feedback if it is working as you want.

Regards,

Adam

View solution in original post

12 REPLIES 12

Model pvz sequence binding at runtime

I created mulitple sequences in a model. Now i have binded it with application parameter . i want to know how can i provide values to that parameter at runtime in Home.js or elsewhere.

basically i want to change the sequence by calling different functions.

Re: Model pvz sequence binding at runtime

Vivek Jain​: Yes, you can initialize and assign values to variables in Home.js and can also write JS functions which you would like to be called in case of some event or activity.

-Durgesh

Re: Model pvz sequence binding at runtime

I am aware of initializing the variables in Home.js.

I want to know in particular about the sequence property of model and how to set it for multiple sequences.?

Re: Model pvz sequence binding at runtime

Hi,

You need to go to the widget property through the $scope. You can find that your model widget has something called sequence property.

3.PNG

Sequences created in Creo software are saved in PVI format and it is a part of the PVZ model file. You can try to open PVZ file as an archive to see that it contains your sequences in separated PVI files.

So now you can try with two things:

1. Assign the sequence name directly to the property like this: $scope.view.wdg['model-1'].sequence = "mySecondSequence";

2. Try to assign it by path like it is shown above. (it can be painful to figure out correct path).

I didn't test it yet, so you can give me a feedback if it is working as you want.

Regards,

Adam

View solution in original post

Re: Model pvz sequence binding at runtime

Also, can check and try

$scope.view.wdg['model-1']['sequence'] = seqname;

Highlighted

Re: Model pvz sequence binding at runtime

We cannot directly provide sequence name. We have to find the fully qualified name which is a pain as said.

I had to download the project and go to \src\phone\components\Home.json to find out the qualified name for the sequence.

so  $scope.view.wdg['model-1'].sequence = "Uploaded/l-Creo 3D - wheelassembly1.pvi";  something of this sort works.

Re: Model pvz sequence binding at runtime

nope this doesn't work.

Re: Model pvz sequence binding at runtime

Glad that I could help. And I can agree that this is painful to get proper sequence name without digging in the PVZ model.

I believe that the first part of path is always the same, so you can make you own JS function which will be just concatenating the path.

Regards,

Adam

Re: Model pvz sequence binding at runtime

Hello

I've tried to use .pvi file in hololens according to proposed solution above and are getting following error.

Uncaught TypeError: Cannot read property 'stepVec' of undefined

    at vuforia-angular.js:1568

And in debug mode I'm getting error on bold marked line:

function loadSequence(url, speed, callback) {

        // ignore speed, native sequencer doesn't have such concept

        var pviParams = {

            modelID: MODEL_ID,

            url: url

        };

        renderer.loadPVI(pviParams, function (sequenceData) {

            // load completed callback

           STEPS = sequenceData.stepVec;

            TOTALSTEPS = STEPS.length;

            FIRST_STEP = 0;

            // if step 0 has acknowledgment, start on step 0, otherwise start on step 1

            if ((TOTALSTEPS > 0) && (STEPS[0].acknowledge === false) ) {

                FIRST_STEP = 1;

            }

            // ThingView might still be on step 0, but the next step to be played is CURRENT_STEP

            CURRENT_STEP = FIRST_STEP;

            if ( callback !== undefined ) {

                callback(undefined, undefined);

            }

        }, function () {

            // load failed callback

            console.log(MODEL_ID + " failed to load pvi " + url);

        });

    }