# Issue: rs.XformCompare() returns unexpected value

Hi,

The documentation states rs.XformCompare(xform1, xform2) should return “0 if xform1=xform2”.
When I run the snippet below, I sometimes get return value 0 from when the matrices are not identical (R1). I would expect to either return -1 or 1 in that case

best regards,
Tim

``````def compareXform():

for itemA in rs.BlockObjects('block_a'):
for itemB in rs.BlockObjects('block_b'):

if rs.IsBlockInstance(itemA) and rs.IsBlockInstance(itemB):
print 'xform_a', rs.BlockInstanceXform(itemA)
print 'xform_b', rs.BlockInstanceXform(itemB)
print rs.XformCompare(rs.BlockInstanceXform(itemA), rs.BlockInstanceXform(itemB))

prints:
> xform_a R0=(1,0,0,46.2819005995964), R1=(0,1,0,156.869812703322), R2=(0,0,1,0), R3=(0,0,0,1)
> xform_b R0=(1,0,0,46.2819005995964), R1=(0,1,0,121.084008261567), R2=(0,0,1,0), R3=(0,0,0,1)
> 0
``````

Yeah something doesn’t seem right. Does this work any better?

``````import Rhino
import rhinoscriptsyntax as rs

def compare_transforms(a, b):
for i in range(0, 4):
for j in range(0, 4):
x = a[i, j]
y = b[i, j]
if x < y: return -1
if x > y: return 1
if x == y: continue
if not x == x: # x is a nan
if not y == y: continue # x and y are nans
return 1 #  x is a nan and y is not
return -1 # y is a nan and x is not
return 0

def test_compare_transforms():
itemA = rs.GetObject('First block instance')
itemB = rs.GetObject('Second block instance')
if rs.IsBlockInstance(itemA) and rs.IsBlockInstance(itemB):
xformA = rs.BlockInstanceXform(itemA)
xformB = rs.BlockInstanceXform(itemB)
print 'xformA:', xformA
print 'xformB:', xformB
print compare_transforms(xformA, xformB)

if __name__ == '__main__':
test_compare_transforms()
``````

– Dale

Thank you @dale!