Community Tip - Learn all about the Community Ranking System, a fun gamification element of the PTC Community. X
I am using a 2D select widget to control the sequence being played. I would like to be able to display different 3D images based on this selection.
Solved! Go to Solution.
Here's an example of doing this with 3 different sequence options. You'll have to update the widget IDs to match your widgets.
$scope.checkSequence = function(){ var sequenceValue= $scope.app.view['Home'].wdg['select-1']['value']; console.log(sequenceValue); var sequenceList = $scope.app.view['Home'].wdg['select-1']['list']; //console.log(sequenceList[0].filename); for (i = 0; i < sequenceList.length; i++){ var sequence = sequenceList[i].filename; if (sequence == sequenceValue){ switch(i){ case 0: $scope.setWidgetProp('3DLabel-1','visible', true); $scope.setWidgetProp('3DImage-1','visible', false); $scope.setWidgetProp('3DImage-2','visible', false); break; case 1: $scope.setWidgetProp('3DImage-1','visible', true); $scope.setWidgetProp('3DLabel-1','visible', false); $scope.setWidgetProp('3DImage-2','visible', false); break; case 2: $scope.setWidgetProp('3DImage-2','visible', true); $scope.setWidgetProp('3DLabel-1','visible', false); $scope.setWidgetProp('3DImage-1','visible', false); break; default: console.log('in show/hide images'); } } } }
Call this function on the "Value Changed' Event for your 2D selector
Here's an example of doing this with 3 different sequence options. You'll have to update the widget IDs to match your widgets.
$scope.checkSequence = function(){ var sequenceValue= $scope.app.view['Home'].wdg['select-1']['value']; console.log(sequenceValue); var sequenceList = $scope.app.view['Home'].wdg['select-1']['list']; //console.log(sequenceList[0].filename); for (i = 0; i < sequenceList.length; i++){ var sequence = sequenceList[i].filename; if (sequence == sequenceValue){ switch(i){ case 0: $scope.setWidgetProp('3DLabel-1','visible', true); $scope.setWidgetProp('3DImage-1','visible', false); $scope.setWidgetProp('3DImage-2','visible', false); break; case 1: $scope.setWidgetProp('3DImage-1','visible', true); $scope.setWidgetProp('3DLabel-1','visible', false); $scope.setWidgetProp('3DImage-2','visible', false); break; case 2: $scope.setWidgetProp('3DImage-2','visible', true); $scope.setWidgetProp('3DLabel-1','visible', false); $scope.setWidgetProp('3DImage-1','visible', false); break; default: console.log('in show/hide images'); } } } }
Call this function on the "Value Changed' Event for your 2D selector
Thank you for your help but I cannot get this to work. I wonder if the reason this is not working due to the way I am doing my select widget. My widget is setup like this. https://community.ptc.com/t5/Studio/Select-Widget-default-value/m-p/611653
The difference is how you have the file names declared in your JSON. In my example i was using 'filename' but you are using 'val'. In the for loop, change the sequence variable declaration to this:
var sequence = sequenceList[i].val;
That should fix it.
Even I am not able to use this code.
I changed the widget id according to code but still it's not working