<!--
{
  "availability" : [
    "iOS: 9.0.0 -",
    "iPadOS: 9.0.0 -",
    "macCatalyst: 13.1.0 -",
    "macOS: 10.11.0 -",
    "tvOS: 9.0.0 -",
    "visionOS: 1.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "ModelIO",
  "identifier" : "/documentation/ModelIO/MDLVoxelArray/voxelExists(atIndex:allowAnyX:allowAnyY:allowAnyZ:allowAnyShell:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Model I/O"
    ],
    "preciseIdentifier" : "c:objc(cs)MDLVoxelArray(im)voxelExistsAtIndex:allowAnyX:allowAnyY:allowAnyZ:allowAnyShell:"
  },
  "title" : "voxelExists(atIndex:allowAnyX:allowAnyY:allowAnyZ:allowAnyShell:)"
}
-->

# voxelExists(atIndex:allowAnyX:allowAnyY:allowAnyZ:allowAnyShell:)

Returns a Boolean value indicating whether the voxel array contains voxel data for the specified index.

```
func voxelExists(atIndex index: MDLVoxelIndex, allowAnyX: Bool, allowAnyY: Bool, allowAnyZ: Bool, allowAnyShell: Bool) -> Bool
```

## Parameters

`index`

An index describing both the location of the voxel within the three-dimensional grid of the voxel array and its relationship to the volume of the object modeled by the voxel array.

`allowAnyX`

If <doc://com.apple.documentation/documentation/Swift/true>, this method treats the x component of the index parameter as a wildcard. If <doc://com.apple.documentation/documentation/Swift/false>, this method requires an exact match for the x component.

`allowAnyY`

If <doc://com.apple.documentation/documentation/Swift/true>, this method treats the y component of the index parameter as a wildcard. If <doc://com.apple.documentation/documentation/Swift/false>, this method requires an exact match for the y component.

`allowAnyZ`

If <doc://com.apple.documentation/documentation/Swift/true>, this method treats the z component of the index parameter as a wildcard. If <doc://com.apple.documentation/documentation/Swift/false>, this method requires an exact match for the z component.

`allowAnyShell`

If <doc://com.apple.documentation/documentation/Swift/true>, this method treats the w (shell level) component of the index parameter as a wildcard. If <doc://com.apple.documentation/documentation/Swift/false>, this method requires an exact match for the shell level component.

## Return Value

<doc://com.apple.documentation/documentation/Swift/true> if the voxel array contains at least one voxel index matching the specified parameters; otherwise <doc://com.apple.documentation/documentation/Swift/false>.

## Discussion

Use the `allowAnyX`, `allowAnyY`, `allowAnyZ`, and `allowAnyShell` parameters to perform wildcard searches. For example:

```swift
// Does a voxel exist at exactly the specified X, Y, Z, and shell level?
exists = voxelArray.voxelExists(atIndex: index, allowAnyX: false, allowAnyY: false, allowAnyZ: false, allowAnyShell: false)
// Does a voxel exist at the specified X, Y, and Z, regardless of shell level?
exists = voxelArray.voxelExists(atIndex: index, allowAnyX: false, allowAnyY: false, allowAnyZ: false, allowAnyShell: true)
// Are there surface voxels anywhere on the XY plane at a specific Z index?
index.w = 0
exists = voxelArray.voxelExists(atIndex: index, allowAnyX: true, allowAnyY: true, allowAnyZ: false, allowAnyShell: false)
// Are there any voxels three layers deep inside the object modeled by the voxel array, regardless of location?
index.w = -3
exists = voxelArray.voxelExists(atIndex: index, allowAnyX: true, allowAnyY: true, allowAnyZ: true, allowAnyShell: false)
```

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)