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

How to turn 3D image files on and off when using a 2D select widget

SOLVED
Highlighted
Marble

How to turn 3D image files on and off when using a 2D select widget

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.

1 ACCEPTED SOLUTION

Accepted Solutions

Re: How to turn 3D image files on and off when using a 2D select widget

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

checkSequence.png

4 REPLIES 4

Re: How to turn 3D image files on and off when using a 2D select widget

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

checkSequence.png

Re: How to turn 3D image files on and off when using a 2D select widget

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

Re: How to turn 3D image files on and off when using a 2D select widget

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.

 

 

Re: How to turn 3D image files on and off when using a 2D select widget

Even I am not able to use this code.

I changed the widget id according to code but still it's not working