I am writing a python program to replace all the walls I currently have in a Maya scene. The program should duplicate an existing wall I have in the scene, then replace every wall in the scene with it. The script properly duplicates the desired wall (Walls_Options:Wall_v*). Unfortunately, the program isn't placing them correctly. It seems to be placing them along the Y axis at random for some reason. It also doesn't rotate them at all. Any help is greatly appreciated.
from pymel.core import *
import random as rnd
wallChoices = ls("Walls_Options:Wall_v*", et="transform") #ls("newBrick", et="transform")
oldWalls = ls("Brick", et="transform")
for oldWall in oldWalls:
select(oldWall, r=True)
makeIdentity(apply=True, t=1, r=1, s=1, n=0)
thisWallPos = xform(oldWall, query=True, worldSpace=True, t=True)
thisWallRot = xform(oldWall, query=True, worldSpace=True, ro=True)
print(oldWall)
print("position is")
print(thisWallPos)
#print("rotation is")
#print(thisWallRot)
newThisWall = duplicate(wallChoices[0])
xform(newThisWall, query=False, worldSpace=True, t=thisWallPos)
######not rotating correctly yet....
xform(newThisWall, query=False, worldSpace=True, rt=thisWallRot)
select(newThisWall, r=True)
move(thisWallPos)
rotate(thisWallRot)
delete(oldWall)
print(newThisWall)
print(xform(newThisWall, query=True, worldSpace=True, rp=True))