Hi Forum,

The rough script below is intended to copy (or move) objects from a location relative to one block insert to a similar location relative to another block insert. It works ok as below but I encountered a few unexpected behaviours in rhinoscriptsyntax,

The first is with rs.GetBoolean - it seems to fail when passed a single item, but is ok with multiples.

The second is with rs.XformMultiply. It gives unexpected results (when blocks are rotated relative to each other), whereas the hand-rolled function MatrixMultiply below works as expected. I’m not sure if I am understanding xforms correctly, or if there is a problem with the method (XformInverse seems fine).

Paul

```
import rhinoscriptsyntax as rs
def BlockTransform():
Objects = rs.GetObjects ("Select objects to transform: ")
#this works:
items = ("Copy", "Yes", "No"),("Copy", "Yes", "No")
results = rs.GetBoolean("Copy objects?: ", items, (False, False))
#this fails:
#items = ("Copy", "Yes", "No")
#results = rs.GetBoolean("Copy objects?: ", items, (False))
if results[0]:
rs.CopyObjects(Objects)
Object0 = rs.GetObject("Select first block:", 4096)
Object1 = rs.GetObject("Select second block:", 4096)
if rs.IsBlockInstance(Object0):
Matrix0 = rs.BlockInstanceXform(Object0)
if rs.IsBlockInstance(Object1):
Matrix1 = rs.BlockInstanceXform(Object1)
Matrix0 = rs.XformInverse(Matrix0)
#this works:
Matrix0 = MatrixMultiply(Matrix0, Matrix1)
#this fails:
#Matrix0 = rs.XformMultiply(Matrix0, Matrix1)
if results[0]:
rs.TransformObjects(Objects, Matrix0, True)
else:
rs.TransformObjects(Objects, Matrix0)
if type(Objects) == type([]):
rs.SelectObjects(Objects)
def MatrixMultiply(U,V):
"""function to multiply two 4x4 transformation matrices
index of resultant is sum of row of first, multiplied by column of second
for whatever reason, this gives the correct result, whereas the inbuilt rhino one does not
"""
W = rs.XformZero()
for i in range(4):
for j in range(4):
W[i, j] = V[i, 0] * U[0,j] + V[i,1] * U[1,j] + V[i,2] * U[2,j] + V[i,3] * U[3,j]
return W
if __name__ == "__main__" :
BlockTransform()
```