Im using the matrix approach to construct the required object’s matrix… It’s more conprehensive, I think.
Sooo it’s a matter of constructing some matrices (for location, rotation, scale + the BASE unit matrix 4x4), then multiply them appropriately:
def Eu_degr(eu): # eu in radians
eu_x,eu_y,eu_z = eu[0],eu[1],eu[2]
eu_x = math.degrees(eu_x)
eu_y = math.degrees(eu_y)
eu_z = math.degrees(eu_z)
eu_degr = Mathutils.Euler(eu_x,eu_y,eu_z)
return eu_degr
def Eu_rad(eu): # eu in degrees
eu_x,eu_y,eu_z = eu[0],eu[1],eu[2]
eu_x = math.radians(eu_x)
eu_y = math.radians(eu_y)
eu_z = math.radians(eu_z)
eu_rad = Mathutils.Euler(eu_x,eu_y,eu_z)
return eu_rad
def Make_object_matrix(lx,ly,lz,rx,ry,rz,sx,sy,sz):
loc_mat = Mathutils.Matrix([0,0,0,0],[0,0,0,0],[0,0,0,0],[lx,ly,lz,0])
scale_mat = Mathutils.Matrix([sx,0,0,0],[0,sy,0,0],[0,0,sz,0],[0,0,0,1])
eu = Mathutils.Euler(rx,ry,rz)
eu_degr = Eu_degr(eu) # in case (rx,ry,rz) are in radians
rot_mat = eu_degr.toMatrix()
new_mat = rot_mat.resize4x4()
ob_mat = new_mat*scale_mat+loc_mat
return ob_mat
Eu_degr and Eu_rad are AUX functions to convert Eulers/rot or lists/tuples into Eulers in degrees or rot in radians. For your task, only the first one is needed
You may wish accelerate the process by directly writing values in the resulting matrix BUT… you need to know what you’re doing and be precise and very careful
Regards,