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

In my case, I need to extract the dimension of object bounding box, we can see it in property tab. But I don’t know how to extract these values into csv file.

So I used the Bounding Ruler filter which is shown in this article https://www.kitware.com/measuring-oriented-bounding-box-axes-paraview/
However, it only show the option of each value at the time (either X, Y or Z). It would be great if there is an option to shown these 3 values at once.


Therefore, I quickly made a script to extract this values.

I am not certain way to extract these. If yes, please share your idea.

Instead of the Ruler, you can try to add the Data Axes Grid on your representation (under the Display section of the properties panel)

Hi Nicolas, is this here? I couldn’t find it.

You need to select the RenderView in order to get it.

My bad, I miss the export to csv part.

My suggestion will display a widget in the 3D view but not allow to save such data. I think the best way to access the Bounds numeric values as shown in Information panel is to use some python code 3. Understanding Data — ParaView Documentation 5.12.0 documentation

e.g., in python shell

GetActiveSource().GetDataInformation().GetBounds()
1 Like

Great, now it showed points. This way is much better than using Ruler.


Is there a way to extract the delta or I have to calculate manually?

1 Like

I think manual operation is required here.

1 Like

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

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}')

1 Like