<!--
{
  "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/voxels(within:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Model I/O"
    ],
    "preciseIdentifier" : "c:objc(cs)MDLVoxelArray(im)voxelsWithinExtent:"
  },
  "title" : "voxels(within:)"
}
-->

# voxels(within:)

Returns a data object containing all voxels within the specified volume.

```
func voxels(within extent: MDLVoxelIndexExtent) -> Data?
```

## Parameters

`extent`

The minimum and maximum corners of the volume for which to retrieve voxel data.

## Return Value

A data object containing [`MDLVoxelIndex`](/documentation/ModelIO/MDLVoxelIndex) values.

## Discussion

The returned <doc://com.apple.documentation/documentation/Foundation/NSData> object contains an array of [`MDLVoxelIndex`](/documentation/ModelIO/MDLVoxelIndex) values describing the locations of voxels within the specified volume as well as their volumetric relationship to the object modeled by the voxel array.

---

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)