ArcGIS Pro 3.8 API Reference Guide
ArcGIS.Core.Geometry Namespace / MultipatchBuilderEx Class / Patches Property
Example

In This Topic
    Patches Property
    In This Topic
    Gets or sets the list of patches for this instance.
    Syntax
    public IList<Patch> Patches {get; set;}
    Public Property Patches As IList(Of Patch)
    Remarks
    The getter returns the reference to the list which can be modified directly. The setter copies the input IList to an internal container. Only the list is copied, not the patches. Note also, that the patches don't hold a reference to the containing multipatch builder. Therefore, changes made to the patches directly, such as adding a missing array of Ms to the patch, will not change the attribute awareness (HasM) of the builder.
    Example
    Construct Multipatch via MultipatchBuilderEx
    {
      var coords_face1 = new List<Coordinate3D>()
    {
      new Coordinate3D(12.495461061000071,41.902603910000039,62.552700000000186),
      new Coordinate3D(12.495461061000071,41.902603910000039,59.504700000004959),
      new Coordinate3D(12.495461061000071,41.902576344000067,59.504700000004959),
      new Coordinate3D(12.495461061000071,41.902603910000039,62.552700000000186),
      new Coordinate3D(12.495461061000071,41.902576344000067,59.504700000004959),
      new Coordinate3D(12.495461061000071,41.902576344000067,62.552700000000186),
    };
    
      var coords_face2 = new List<Coordinate3D>()
    {
      new Coordinate3D(12.495461061000071, 41.902576344000067, 62.552700000000186),
      new Coordinate3D(12.495461061000071, 41.902576344000067, 59.504700000004959),
      new Coordinate3D(12.495488442000067, 41.902576344000067, 59.504700000004959),
      new Coordinate3D(12.495461061000071, 41.902576344000067, 62.552700000000186),
      new Coordinate3D(12.495488442000067, 41.902576344000067, 59.504700000004959),
      new Coordinate3D(12.495488442000067, 41.902576344000067, 62.552700000000186),
    };
    
      var coords_face3 = new List<Coordinate3D>()
    {
      new Coordinate3D(12.495488442000067, 41.902576344000067, 62.552700000000186),
      new Coordinate3D(12.495488442000067, 41.902576344000067, 59.504700000004959),
      new Coordinate3D(12.495488442000067, 41.902603910000039, 59.504700000004959),
      new Coordinate3D(12.495488442000067, 41.902576344000067, 62.552700000000186),
      new Coordinate3D(12.495488442000067, 41.902603910000039, 59.504700000004959),
      new Coordinate3D(12.495488442000067, 41.902603910000039, 62.552700000000186),
    };
    
      var coords_face4 = new List<Coordinate3D>()
    {
      new Coordinate3D(12.495488442000067, 41.902576344000067, 59.504700000004959),
      new Coordinate3D(12.495461061000071, 41.902576344000067, 59.504700000004959),
      new Coordinate3D(12.495461061000071, 41.902603910000039, 59.504700000004959),
      new Coordinate3D(12.495488442000067, 41.902576344000067, 59.504700000004959),
      new Coordinate3D(12.495461061000071, 41.902603910000039, 59.504700000004959),
      new Coordinate3D(12.495488442000067, 41.902603910000039, 59.504700000004959),
    };
    
      var coords_face5 = new List<Coordinate3D>()
    {
      new Coordinate3D(12.495488442000067, 41.902603910000039, 59.504700000004959),
      new Coordinate3D(12.495461061000071, 41.902603910000039, 59.504700000004959),
      new Coordinate3D(12.495461061000071, 41.902603910000039, 62.552700000000186),
      new Coordinate3D(12.495488442000067, 41.902603910000039, 59.504700000004959),
      new Coordinate3D(12.495461061000071, 41.902603910000039, 62.552700000000186),
      new Coordinate3D(12.495488442000067, 41.902603910000039, 62.552700000000186),
    };
    
      var coords_face6 = new List<Coordinate3D>()
    {
      new Coordinate3D(12.495488442000067, 41.902603910000039, 62.552700000000186),
      new Coordinate3D(12.495461061000071, 41.902603910000039, 62.552700000000186),
      new Coordinate3D(12.495461061000071, 41.902576344000067, 62.552700000000186),
      new Coordinate3D(12.495488442000067, 41.902603910000039, 62.552700000000186),
      new Coordinate3D(12.495461061000071, 41.902576344000067, 62.552700000000186),
      new Coordinate3D(12.495488442000067, 41.902576344000067, 62.552700000000186),
    };
    
      // materials
      var materialRed = new BasicMaterial();
      materialRed.Color = System.Windows.Media.Colors.Red;
    
      var materialTransparent = new BasicMaterial();
      materialTransparent.Color = System.Windows.Media.Colors.White;
      materialTransparent.TransparencyPercent = 80;
    
      var blueTransparent = new BasicMaterial(materialTransparent);
      blueTransparent.Color = System.Windows.Media.Colors.SkyBlue;
    
      // create a list of patch objects
      var patchesList = new List<Patch>();
    
      // create the multipatchBuilderEx object
      var mpb = new ArcGIS.Core.Geometry.MultipatchBuilderEx();
    
      // make each patch using the appropriate coordinates and add to the patch list
      var patch = mpb.MakePatch(PatchType.Triangles);
      patch.Coords = coords_face1;
      patchesList.Add(patch);
    
      patch = mpb.MakePatch(PatchType.Triangles);
      patch.Coords = coords_face2;
      patchesList.Add(patch);
    
      patch = mpb.MakePatch(PatchType.Triangles);
      patch.Coords = coords_face3;
      patchesList.Add(patch);
    
      patch = mpb.MakePatch(PatchType.Triangles);
      patch.Coords = coords_face4;
      patchesList.Add(patch);
    
      patch = mpb.MakePatch(PatchType.Triangles);
      patch.Coords = coords_face5;
      patchesList.Add(patch);
    
      patch = mpb.MakePatch(PatchType.Triangles);
      patch.Coords = coords_face6;
      patchesList.Add(patch);
    
      patchesList[0].Material = materialRed;
      patchesList[1].Material = materialTransparent;
      patchesList[2].Material = materialRed;
      patchesList[3].Material = materialRed;
      patchesList[4].Material = materialRed;
      patchesList[5].Material = blueTransparent;
    
      // assign the patches to the multipatchBuilder
      mpb.Patches = patchesList;
    
      // check which patches currently contain the material
      var red = mpb.QueryPatchIndicesWithMaterial(materialRed);
      //   red should be [0, 2, 3, 4]
      // call ToGeometry to get the multipatch
      multipatch = mpb.ToGeometry() as Multipatch;
    }
    Construct Multipatch from another Multipatch
    {
      TextureResource brickTextureResource = null;
      BasicMaterial brickMaterialTexture = new BasicMaterial();
      var coords = new List<Coordinate3D>();
    
      // 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, mapPoint);
        }
    
        // 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 the multipatchBuilderEx object
      var builder = new ArcGIS.Core.Geometry.MultipatchBuilderEx(multipatch);
      //   - 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 Home, Pro, Enterprise (64 bit)

    ArcGIS Pro version: 3.0 or higher.
    See Also