There are actually 3 questions. Any help would be really appreciated.
-
How to get local offset of a control with Python? I’ve found a function to get global offset unreal.RigHierarchy.get_global_control_offset_transform but I don’t see a function to get local offset.
-
What means
initial=True/False
in function unreal.RigHierarchy.set_control_offset_transform() Well, yes it looks like self-explanatory, but what is an initial value in that case? The behavior is different when switch betnween True/False. But I cannot figured it out. -
Have a look please at the script below. The main idea is to move local(initial/current) transfomations to local offset and all local(initial/current) become 0. I cannot realize why my script sets right transformations, the print prints them right too, but it appears different/wrong in editor and 3d viewport? What could be missed here?
new_controls = ['control_name_1, control_name_2',...]
for new_ctrl in new_controls:
print('/////////////////////////////////')
new_ctrl_loc_transform = rig.hierarchy.get_local_transform(unreal.RigElementKey(type=unreal.RigElementType.CONTROL, name=new_ctrl), initial=True) // Get initial local transforms
print(new_ctrl_loc_transform)
rig.hierarchy.set_local_transform(unreal.RigElementKey(type=unreal.RigElementType.CONTROL, name=new_ctrl), unreal.Transform(unreal.Vector(0,0,0), unreal.Rotator(0,0,0), unreal.Vector(1,1,1)), initial=True) // Reset initial local transforms to 0
print(rig.hierarchy.get_local_transform(unreal.RigElementKey(type=unreal.RigElementType.CONTROL, name=new_ctrl), initial=True))
rig.recompile_vm() //Recompile
print(rig.hierarchy.get_local_transform(unreal.RigElementKey(type=unreal.RigElementType.CONTROL, name=new_ctrl), initial=True))
print(new_ctrl_loc_transform)
rig.hierarchy.set_control_offset_transform(unreal.RigElementKey(type=unreal.RigElementType.CONTROL, name=new_ctrl), new_ctrl_loc_transform, initial=True) // Set previously got initial local transformations to local offset
print(rig.hierarchy.get_local_transform(unreal.RigElementKey(type=unreal.RigElementType.CONTROL, name=new_ctrl), initial=True))
rig.hierarchy.set_local_transform(unreal.RigElementKey(type=unreal.RigElementType.CONTROL, name=new_ctrl), unreal.Transform(unreal.Vector(0,0,0), unreal.Rotator(0,0,0), unreal.Vector(1,1,1)), initial=True) //Reset initial local trans. one more time(just in case)
print(rig.hierarchy.get_local_transform(unreal.RigElementKey(type=unreal.RigElementType.CONTROL, name=new_ctrl), initial=True))
rig.recompile_vm() // Recompile
print(rig.hierarchy.get_local_transform(unreal.RigElementKey(type=unreal.RigElementType.CONTROL, name=new_ctrl), initial=True))
Thanks