Skip to main content
1-Visitor
March 10, 2017
Solved

Can't use more than one sequence animation in a single experience in ThingWorx studio.

  • March 10, 2017
  • 2 replies
  • 13597 views

I am trying to develop an experience in ThingWorx Studio where in each view different sequence will be shown. But after adding one pvz+pvi, when I am trying to go to the next view and another pvz+pvi, the pvi file is not getting uploaded. Please help me with the problem...

Thank you...

Best answer by mvonhasselbach

Hi Dipika, Parnaz,

sorry for the late reply - was stuck in project work the last two weeks.

Checking and testing the functionality today I found that there is a slight change based on the new renderers. Before 1.10 you had to extract the *.pvi files from the *.pvz file - now this is not required anymore. Before you had to set the complete relative path as value in the binding to the sequence property of the model widget, now you only need the base filename (the complete path works as well - it truncates it to the base name).

Based on this info you can assign the Figure in two ways:

  1. Via Javascript: e.g. use a Button widget and add the following line to the Click Event handler:

setWidgetProp( 'model-1', 'sequence', 'Figure 1.pvi');

     where:

    • model-1 is the ID of the model widget. You have to adjust it to your experience design.
    • sequence is the property name. This is always the same in this case.
    • Figure 1.pvi is the value of the property. You should use one of the values that you see in the dropdown for Sequence URL

     Here is a screenshot of this event handler:

    

     2. Alternatively you can use connection bindings (with or without filters). Here is a slick example of a dropdown with a hardcoded value set, that it gets from a application parameter.

The app param value is a JSON formatted array. You have to use double-dashes (" not ' !) in it. In this example it is:

[{"val":"Figure 1.pvi"},{"val":"Figure 2.pvi"}]

The object attribute name val must be specified in the Value Field and Display Field properties of the Select widget.

The app param is then bound to the List property of the Select widget. This binding has a filter on it with the following expression:

return angular.fromJson(value);

Finally you bind the Value property of the Select widget to the Sequence URL property of the Model widget and that's it.

Have fun!

2 replies

12-Amethyst
March 13, 2017

Hi Dipika,

do you use multiple pvz files and multiple model widgets?

Or do you have one pvz with multiple animations? You can get multiple animations in one pvz file by creating multiple Figures. This will result in multiple pvi files inside the pvz. If you want to use them and switch them e.g. by javascript code, you have to extract the pvi files from the pvz (rename the pvz to *.zip and extract it) and add these pvi files to the Resources. You can then select and also switch the sequences by javascript code or by connections with filters (see Using Connection Filters for state-based rendering and value formatting). You may want to rename the pvi files so that you can better identify them.

I used this approach and it worked fine. I haven't tested it with 1.10 yet though.

Cheers, moritz

dsengupta1-VisitorAuthor
1-Visitor
March 16, 2017

Hi Moritz,

Thanks for your reply. Can you give me any reference material for switching the sequences by javascript code?

Thanks,

Dipika

1-Visitor
March 23, 2017

Did you find a solution or JS code for switching? If so pls share it. I need that too.

Thanks

12-Amethyst
July 7, 2017

I found a little error in the documentation above where I specify the input arguments for the setWidgetProp function.

  • Figure 1.pvi is the value of the property. You should use one of the names of the pvi files inside the pvz (zip) file. The values that you see in the dropdown can be truncated! In my case the dropdown shows Figure 1 and the corresponding pvi file name inside the pvz is l-Creo 3D - Figure 1.pvi.
1-Visitor
September 6, 2017

Hi Moritz,

I have some queries would you please help me out in these ( Studio version: 8.0.3 😞

  1. My drop down list works only when I provide l-Creo 3D - Figure 1.pvi​ ​and not when I provide Figure 1​ ​in Application Parameter. why?
  2. My drop down list shows complete name of sequence i.e l-Creo 3D - Figure 1.pvi​ how can I truncate/limit it to just to show Figure 1​?
  3. How can I call a click event of a button in Home.JS after assigning a sequence to my model?

For ex:

     $scope.sequence1 = function() {

          $scope.view.wdg['model-1']['sequence'] = 'l-Creo 3D - Figure 1.pvi';

     }

Thank you

Shashank

1-Visitor
September 18, 2017

Hi,

This is regarding my 2nd & 3rd query:

2nd Query​:    To resolve my 2nd query, I have done following steps:

    1. I have written simple "Figure 1" in Application Parameter(anims) as a JSON value. (No "l-Creo 3D" & no ".pvi" extension)
    2. I have added one filter to the binding between the "Value" property of "Select" Widget and "Sequence" of Model.

                                        Filter Details:

    • Filter Name: ​sequenceName
    • Filter Body:​ return "l-Creo 3D - " + value + ".pvi";

​3rd Query​:     In 3rd query, actually I wanted to assign a sequence to a model and than call a click event of a button. So that the assigned sequence could be played. (The button's click event would be binded to "PlayAll" service of model)

To achieve this functionality I have done some work around. Instead of calling button's click event I am calling "PlayAll" service of model.

For Ex:

$scope.sequence1 = function() {

     setTimeout(function() {

          $scope.$apply(function() {

                    $scope.view.wdg['model-1'].sequence = "Uploaded/l-Creo 3D - Figure 1.pvi";

                    angular.element(document.getElementById('model-1')).scope().playAll();

          });

     }, 6000);

}

The complete reference can be found at How to play all the Sequences (.pvi), one by one on a single click of a button?​ discussion.

Thank you,

Shashank