Hi Team,
I have certain co-ordinate values in xformOP:transform attribute, from which I was trying to map xformOp:translate, xformOp:rotateXYZ, and xformOp:scale attributes after creating a light from the code. I copied the individual values from xformOp:transform and set them in the appropriate attributes (translate, rotateXYZ, and scale). As a result, I am now able to see the values in their properties(UI).
However, despite successfully copying the values, I noticed that the placement of the created lights still remains at the default position (0, 0, 0), instead of at the translate co-ordinates which has been mapped. Please let me know the cause and resolution for the same
Please find attached below different code snippets that I tried to map the values
1st Method:
if attributeName == "xformOp:transform":
x = attribute.Get()[3][0]
y = attribute.Get()[3][1]
z = attribute.Get()[3][2]
newLightPrim.GetAttribute('xformOp:translate').Set(Gf.Vec3d(x, y, z))
newLightPrim.GetAttribute('xformOp:scale').Set((1,1,1))
newLightPrim.GetAttribute('xformOp:rotateXYZ').Set((90,0,90))
2nd Method:
if attributeName == "xformOp:transform":
x = attribute.Get()[3][0]
y = attribute.Get()[3][1]
z = attribute.Get()[3][2]
UsdGeom.XformCommonAPI(newLightPrim).SetTranslate(Gf.Vec3d(x, y, z))
newLightPrim.GetAttribute('xformOp:scale').Set((1,1,1))
newLightPrim.GetAttribute('xformOp:rotateXYZ').Set((90,0,90))
3rd Method:
if attributeName == "xformOp:transform":
x = attribute.Get()[3][0]
y = attribute.Get()[3][1]
z = attribute.Get()[3][2]
value = attribute.Get()
if isinstance(value, Gf.Matrix4d):
matrix = value
else:
matrix = Gf.Matrix4d(*value)
eps_unused, scale_orient_mat_unused, abs_scale, rot_mat, abs_position, persp_mat_unused = (
matrix.Factor()
)
rot_mat.Orthonormalize(False)
abs_rotation = Gf.Rotation.DecomposeRotation3(
rot_mat, Gf.Vec3d.XAxis(), Gf.Vec3d.YAxis(), Gf.Vec3d.ZAxis(), 1.0
)
newLightPrim.GetAttribute('xformOp:translate').Set(Gf.Vec3d(x, y, z))
newLightPrim.GetAttribute('xformOp:scale').Set((abs_scale[0],abs_scale[1],abs_scale[2]))
newLightPrim.GetAttribute('xformOp:rotateXYZ').Set((abs_rotation[0],abs_rotation[1],abs_rotation[2]))