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

We are working to address an issue with subscription email notifications. In the meantime, be sure to check your favorite boards for new topics.

Button click event

TP_9428687
1-Newbie

Button click event

I have created a button toggle in my project. When this is pressed, the sequence should pause.

TP_9428687_0-1708432520842.png

Unfortunately the code doesn't quite work yet. Since I have several pvi files I cannot assign a specific sequence to my model. If I'm correct, as soon as one of the two sequences is played, it will be assigned to the model, right?

Unfortunately, I'm not very familiar with programming and wanted to ask whether the code generally fits. Then maybe I can look for the error somewhere else. Additionally, I would like to know if I need to give a service to the button's "Pressed" event?

TP_9428687_2-1708432893666.png

 

 

Translated by the Community Moderation using Google Translate
-----------------------------------------------------------------------------------------------

 

Ich habe einen Button-Toggle in meinem Projekt angelegt. Wenn dieser gedrückt wird, soll die Sequenz pausieren. 

TP_9428687_0-1708432520842.pngTP_9428687_1-1708432560922.png

Leider funktioniert der Code noch nicht ganz. Da ich mehrere pvi Dateien habe kann ich mein Modell keine spezifische Sequenz zuweisen. Wenn ich richtig liege, wird sobald eine der beide Sequenzen abgespielt werden, diese dem Modell zugewiesen, oder?

Ich kenne mich mit der Programmierung leider nicht so gut aus und wollte fragen, ob der Code im generellen so passt. Dann kann ich vielleicht woanders den Fehler suchen. Zusätzlich würde ich gerne wssen, ob ich dem Event "Pressed" des Buttons einen Service geben muss?

TP_9428687_2-1708432893666.png

 

1 REPLY 1

Hi @TP_9428687 , 

just to clarified you want to call a service to a model widget here the name "Transportband" right?

  1. - so calling only this service you do not need to use really javacode but could bind directly your button to the desired service. This will not make an difference so far I know
  2. To play anything - you need a sequence (that what is saved as pvi file inside the pvz model file) You can extract the pvi file from there and saved it in the upload folder. sometimes I had an issue where this was workaround for HoloLens device
  3. when you use the services play , or playAll of Modelwidget - this requires that the sequence is set at the current time - the sequence property should point to one of the defined figures /where we have the correspoinding pvi file (pvi file should be generated to specific pvz - only for this pvz it work)
  4. javascript you can use to set pvi , step and to play - some code :
    /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    $scope.app.playModelStep = function (sequence,modelName,step_number,play) {
    //sequence -sequnece name e.g. TestFigure1 - as shown in UI
    //modelName - model name e.g. model-1 widget
    //step_number - set this number to current step
    //play   true/false execute play for the model
    console.log("played Step:: "+step_number)
    $timeout(function () {
      $scope.$applyAsync(()=>{$scope.setWidgetProp(modelName, 'sequence',  '');});
     },10);
      $timeout(function () {
      $scope.$applyAsync(()=>{$scope.setWidgetProp(modelName, 'sequence',  'app/resources/Uploaded/l-Creo 3D - '+sequence +'.pvi');});    
      },50);
      $timeout(function () {    
      $scope.$applyAsync(()=>{$scope.setWidgetProp(modelName, 'currentStep', parseInt(step_number));});
      
     if(play)   //check if play should be applyed
      
     $timeout(function () {angular.element(document.getElementById(modelName)).scope().play();  }, 100)
       //angular.element(document.getElementById(modelName)).scope().play(); }, 100);    
                          }, 500);
    };
    ​

so calling this example there e.g.

 

 

 $timeout(  $scope.app.playModelStep( 'app/resources/Uploaded/l-Creo 3D - '+'Figure 2',"model-1",playSTep,"true") ,300);

 

where we have a figure /pvi file saved in Upload project folder and the name is (that what we see in UI: Figure 2

Top Tags