# Bounding Ruler filter: adding an option to show X, Y, Z delta

**URL:** https://discourse.paraview.org/t/bounding-ruler-filter-adding-an-option-to-show-x-y-z-delta/15274
**Category:** ParaView Support
**Created:** [August 22, 2024, 7:13am UTC](https://discourse.paraview.org/t/bounding-ruler-filter-adding-an-option-to-show-x-y-z-delta/15274 "2024-08-22T07:13:13Z")
**Posts on this page:** 1
**Showing post:** 8

<div class="post-metadata">

### Author: ![NinhGhoster](https://discourse.paraview.org/user_avatar/discourse.paraview.org/ninhghoster/32/15061_2.png) [@NinhGhoster](https://discourse.paraview.org/u/NinhGhoster)
#### Post date: [August 22, 2024, 10:05am UTC](https://discourse.paraview.org/t/bounding-ruler-filter-adding-an-option-to-show-x-y-z-delta/15274/8 "2024-08-22T10:05:58Z")

</div>

Thanks for your help. I leave this script to calculate the delta here in case anyone needs

```auto
import os
import csv

# Function to generate a unique file name
def get_unique_filepath(basepath, index):
    return f"{basepath}_{index}.csv"

# Base filepath (directory + base name)
base_filepath = 'C:/Users/Dustwun/Desktop/firebrand_test_detector' # Define your base path

# Function to calculate delta from bounding box
def calculate_delta(bounds):
    xmin, xmax, ymin, ymax, zmin, zmax = bounds
    delta_x = xmax - xmin
    delta_y = ymax - ymin
    delta_z = zmax - zmin
    return delta_x, delta_y, delta_z

# Get the bounding box points from the active source
bounding_box = GetActiveSource().GetDataInformation().GetBounds()
if not bounding_box:
    raise ValueError("Bounding box could not be retrieved. Ensure the active source has valid bounds.")

# Calculate delta values
delta_x, delta_y, delta_z = calculate_delta(bounding_box)

# Get the current time step from the time manager
time_keeper = GetTimeKeeper()
current_time_step = time_keeper.Time

# Generate a unique file name to prevent overwriting
index = 1
filepath = get_unique_filepath(base_filepath, index)
while os.path.exists(filepath):
    index += 1
    filepath = get_unique_filepath(base_filepath, index)

# Write to CSV
with open(filepath, mode='w', newline='') as file:
    writer = csv.writer(file)
    writer.writerow(['ObjectID', 'Delta_X', 'Delta_Y', 'Delta_Z'])
    writer.writerow([current_time_step, delta_x, delta_y, delta_z])

# Optional: Print the dimensions for verification
print(f'Bounding Box Deltas (X, Y, Z): {delta_x}, {delta_y}, {delta_z}')
print(f'Data saved to: {filepath}')
print(f'ObjectID (Time Step): {current_time_step}')

```

 ![image](https://discourse.paraview.org/uploads/default/original/2X/f/f474f4900a9193f9a28cbe0fb1d4031f011c52c2.png)

---

_[View the full topic](https://discourse.paraview.org/t/bounding-ruler-filter-adding-an-option-to-show-x-y-z-delta/15274)._
