Community Tip - Learn all about the Community Ranking System, a fun gamification element of the PTC Community. X
I have created a button toggle in my project. When this is pressed, the sequence should pause.
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?
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.
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?
Hi @TP_9428687 ,
just to clarified you want to call a service to a model widget here the name "Transportband" right?
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
$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