ArcGIS Pro 3.3 API Reference Guide
ArcGIS.Core.Geometry Namespace / Patch Class / Material Property
Example

In This Topic
    Material Property
    In This Topic
    Gets or sets the material for this patch by reference.
    Syntax
    public Material Material {get; set;}
    Public Property Material As Material
    Remarks
    Patches may share the same material. The getter returns the material for this patch builder by reference. A change to the returned material changes the material in any patch containing the material. Patches that share the material will have the same material index returned from GetPatchMaterialIndex. To remove the material from this patch, set the material to null.
    Example
    Construct Multipatch from another Multipatch
    // create the multipatchBuilderEx object
    var builder = new ArcGIS.Core.Geometry.MultipatchBuilderEx(multipatch);
    
    // check some properties
    bool hasM = builder.HasM;
    bool hasZ = builder.HasZ;
    bool hasID = builder.HasID;
    bool isEmpty = builder.IsEmpty;
    bool hasNormals = builder.HasNormals;
    
    var patches = builder.Patches;
    int patchCount = patches.Count;
    
    // if there's some patches
    if (patchCount > 0)
    {
      int pointCount = builder.GetPatchPointCount(0);
    
      // replace the first point in the first patch
      if (pointCount > 0)
      {
        // get the first point
        var pt = builder.GetPoint(0, 0);
        builder.SetPoint(0, 0, newPoint);
      }
    
      // check which patches currently contain the texture
      var texture = builder.QueryPatchIndicesWithTexture(brickTextureResource);
    
      // assign a texture material
      patches[0].Material = brickMaterialTexture;
    }
    
    // update the builder for M awareness
    builder.HasM = true;
    // synchronize the patch attributes to match the builder attributes
    //   in this instance because we just set HasM to true on the builder, each patch will now get a default M value for it's set of coordinates
    builder.SynchronizeAttributeAwareness();
    
    // call ToGeometry to get the multipatch
    multipatch = builder.ToGeometry() as Multipatch;
    
    // multipatch.HasM will be true
    
    Construct 3D special Multipatch shapes
    var sr = MapView.Active.Map.SpatialReference;
    
    var extent = MapView.Active.Extent;
    var center = extent.Center;
    var centerZ = MapPointBuilderEx.CreateMapPoint(center.X, center.Y, 500, sr);
    
    // cube
    multipatch = ArcGIS.Core.Geometry.MultipatchBuilderEx.CreateMultipatch(MultipatchConstructType.Cube, centerZ, 200, sr);
    // tetrahedron
    multipatch = ArcGIS.Core.Geometry.MultipatchBuilderEx.CreateMultipatch(MultipatchConstructType.Tetrahedron, centerZ, 200, sr);
    // diamond
    multipatch = ArcGIS.Core.Geometry.MultipatchBuilderEx.CreateMultipatch(MultipatchConstructType.Diamond, centerZ, 200, sr);
    // hexagon
    multipatch = ArcGIS.Core.Geometry.MultipatchBuilderEx.CreateMultipatch(MultipatchConstructType.Hexagon, centerZ, 200, sr);
    
    // sphere frame
    multipatch = ArcGIS.Core.Geometry.MultipatchBuilderEx.CreateMultipatch(MultipatchConstructType.SphereFrame, centerZ, 200, 0.8, sr);
    // sphere
    multipatch = ArcGIS.Core.Geometry.MultipatchBuilderEx.CreateMultipatch(MultipatchConstructType.Sphere, centerZ, 200, 0.8, sr);
    // cylinder
    multipatch = ArcGIS.Core.Geometry.MultipatchBuilderEx.CreateMultipatch(MultipatchConstructType.Cylinder, centerZ, 200, 0.8, sr);
    // cone
    multipatch = ArcGIS.Core.Geometry.MultipatchBuilderEx.CreateMultipatch(MultipatchConstructType.Cone, centerZ, 200, 0.8, sr);
    
    
    // use the builder to add materials or textures
    //   - create a cone with a material
    builder = new MultipatchBuilderEx(MultipatchConstructType.Cone, centerZ, 200, 0.8, sr);
    
    BasicMaterial faceMaterial = new BasicMaterial();
    faceMaterial.Color = System.Windows.Media.Color.FromRgb(255, 0, 0);
    faceMaterial.Shininess = 150;
    faceMaterial.TransparencyPercent = 50;
    faceMaterial.EdgeWidth = 20;
    
    foreach (var patch in builder.Patches)
      patch.Material = faceMaterial;
    
    multipatch = builder.ToGeometry() as Multipatch;
    Requirements

    Target Platforms: Windows 11, Windows 10

    ArcGIS Pro version: 3 or higher.
    See Also