ArcGIS Pro 3.7 API Reference Guide
ArcGIS.Desktop.Mapping Namespace / VoxelLayer Class / SetVisualization Method
The visualization mode to set
Example

In This Topic
    SetVisualization Method
    In This Topic
    Sets the visualization mode. This method must be called on the MCT. Use QueuedTask.Run.
    Syntax
    Public Sub SetVisualization( _
       ByVal visualization As VoxelVisualization _
    ) 
    public void SetVisualization( 
       VoxelVisualization visualization
    )

    Parameters

    visualization
    The visualization mode to set
    Exceptions
    ExceptionDescription
    This method or property must be called within the lambda passed to QueuedTask.Run
    Example
    Change the Voxel Visualization
    {
      // Note: call within QueuedTask.Run()
      {
        //Change the visualization to Volume
        //e.g. for creating slices
        voxelLayer.SetVisualization(VoxelVisualization.Volume);
    
        //Change the visualization to Surface
        //e.g. to create isosurfaces and sections
        voxelLayer.SetVisualization(VoxelVisualization.Surface);
      }
    }
    Check CanCreateIsoSurface
    {
      //Visualization must be surface or CanCreateIsosurface will return
      //false
      if (voxelLayer.Visualization != VoxelVisualization.Surface)
        voxelLayer.SetVisualization(VoxelVisualization.Surface);
    
      //Get the variable profile on which to create the iso surface
      var variable = voxelLayer.SelectedVariableProfile;
      //or use ...voxelLayer.GetVariableProfiles().First(....
    
      // o Visualization must be Surface
      // o Variable profile must be continuous
      // o Variable MaxNumberofIsoSurfaces must not have been reached...
      if (variable.CanCreateIsosurface)
      {
        //Do the create
      }
    }
    Create Isosurface
    {
      // Note: call within QueuedTask.Run()
      {
        //Visualization must be surface
        if (voxelLayer.Visualization != VoxelVisualization.Surface)
          voxelLayer.SetVisualization(VoxelVisualization.Surface);
    
        //Get the variable profile on which to create the iso surface
        var variable = voxelLayer.SelectedVariableProfile;
    
        // o Visualization must be Surface
        // o Variable profile must be continuous
        // o Variable MaxNumberofIsoSurfaces must not have been reached...
        if (variable.CanCreateIsosurface)
        {
          //Note: calling create if variable.CanCreateIsosurface == false
          //will trigger an InvalidOperationException
    
          //Specify a voxel value for the iso surface
    
          var min = variable.Statistics.MinimumValue;
          var max = variable.Statistics.MaximumValue;
          var mid = (max + min) / 2;
    
          //color range (i.e. values that are being rendered)
          var renderer = variable.Renderer as CIMVoxelStretchRenderer;
          var color_min = renderer.ColorRangeMin;
          var color_max = renderer.ColorRangeMax;
    
          //keep the surface within the current color range (or it
          //won't render)
          if (mid < color_min)
          {
            mid = renderer.ColorRangeMin;
          }
          else if (mid > color_max)
          {
            mid = renderer.ColorRangeMax;
          }
    
          //Create the iso surface
          var suffix = Math.Truncate(mid * 100) / 100;
          variable.CreateIsosurface(new IsosurfaceDefinition()
          {
            Name = $"Surface {suffix}",
            Value = mid,
            IsVisible = true
          });
        }
      }
    }
    Requirements

    Target Platforms: Windows 11 Home, Pro, Enterprise (64 bit)

    ArcGIS Pro version: 3.0 or higher.
    See Also