Skip to main content

Check Non Zero Transform

# CHECK NON ZERO TRANSFORM

import pymel.core as pm

def is_within_tolerance(value, tolerance=0.001):
return -tolerance <= value <= tolerance

def is_scale_within_tolerance(value, tolerance=0.001):
return 1 - tolerance <= value <= 1 + tolerance

def find_non_zero_transform_objects():
# Find all objects in the scene
all_objects = pm.ls()

# Filter objects that end with exactly "_con"
con_objects = [obj for obj in all_objects if obj.name().endswith('_con')]

non_zero_transform_objects = []

for obj in con_objects:
# Check if translation, rotation, and scale are within the tolerance range
translation = pm.xform(obj, query=True, translation=True, worldSpace=False)
rotation = pm.xform(obj, query=True, rotation=True, worldSpace=False)
scale = pm.xform(obj, query=True, scale=True, worldSpace=False)

if (any(not is_within_tolerance(val) for val in translation + rotation) or
any(not is_scale_within_tolerance(val) for val in scale)):
non_zero_transform_objects.append(obj)

return non_zero_transform_objects

# Run the function and print the results
non_zero_transform_objects = find_non_zero_transform_objects()
print("Objects with non-zero transforms:", non_zero_transform_objects)