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

Community Tip - If community subscription notifications are filling up your inbox you can set up a daily digest and get all your notifications in a single email. X

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

Wayne_Beck
12-Amethyst

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.

ACCEPTED SOLUTION

Accepted Solutions

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

View solution in original post

4 REPLIES 4

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

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.

 

 

manojpandey
13-Aquamarine
(To:tmccombie)

Even I am not able to use this code.

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

Announcements

Top Tags