Lord Ashes (9/28/2020)
This is very impressive. I'm just starting out trying to make some Python scripts and I can't seem to find any script examples of simple bone manipulation (i.e. rotation). Your script obviously works with bones. Would you be able to post a small portion of your script (or a sample) of what needs to be done to manipulate a selected Avatar's bones? I posted this as a question in the forum but no one is answering.Hi Lord Ashes
Here is a snippet that shoud get you going.
import math, RLPy
#-- Get Characters from current scene --#
avatar_list = RLPy.RScene.GetAvatars()
#-- Get First Character --#
avatar = avatar_list[0]
#-- Get Motion Bone Data --#
motion_bone = avatar.GetSkeletonComponent().GetMotionBones()
#-- Get First Clip --#
animation_clip = avatar.GetSkeletonComponent().GetClip(0)
#-- Extend the Clip length --#
#animation_clip.SetLength(RLPy.RTime(5000))
time = RLPy.RGlobal_GetTime()
#-- Find head bone --#
for bone in motion_bone:
if bone.GetName() == "RL_Head":
#-- Get Key from Layer --#
head_control = animation_clip.GetControl("Layer", bone)
data_block = head_control.GetDataBlock()
float_control_rotate_x = data_block.GetControl("Rotation/RotationX")
#-- Set Key in current time to rotate the head bone to 90 degree --#
float_control_rotate_x.SetValue(time, math.radians(45))
if bone.GetName() == "RL_L_Thigh":
#-- Get Key from Layer --#
head_control = animation_clip.GetControl("Layer", bone)
data_block = head_control.GetDataBlock()
float_control_rotate_x = data_block.GetControl("Rotation/RotationX")
#-- Set Key in current time to rotate the head bone to 90 degree --#
float_control_rotate_x.SetValue(time, math.radians(-45))
if bone.GetName() == "RL_L_Calf":
#-- Get Key from Layer --#
head_control = animation_clip.GetControl("Layer", bone)
data_block = head_control.GetDataBlock()
float_control_rotate_x = data_block.GetControl("Rotation/RotationX")
#-- Set Key in current time to rotate the head bone to 90 degree --#
float_control_rotate_x.SetValue(time, math.radians(-40))
# if bone.GetName() == "RL_L_Foot":
# #-- Get Key from Layer --#
# head_control = animation_clip.GetControl("Layer", bone)
# data_block = head_control.GetDataBlock()
# float_control_rotate_x = data_block.GetControl("Rotation/RotationX")
# float_control_rotate_x = data_block.GetControl("Position/PositionX")
# #-- Set Key in current time to rotate the head bone to 90 degree --#
# float_control_rotate_x.SetValue(RLPy.RGlobal.GetTime(), math.radians(-15)) #RLPy.RVariant(35) math.radians(-45)
# avatar_list = RLPy.RScene.GetAvatars()
# avatar = avatar_list[0]
# Motion Bone: RL_L_Calf
# Motion Bone: RL_L_Toe
# Motion Bone: RL_Spine02
# Motion Bone: RL_L_Clavicle
# Motion Bone: RL_L_Thigh
# Motion Bone: RL_Waist
# Motion Bone: RL_Pelvis
# Motion Bone: RL_R_Toe
# Motion Bone: RL_Head
# Motion Bone: RL_Hips
# Motion Bone: RL_R_Thigh
# Motion Bone: RL_L_UpperArm
# Motion Bone: RL_L_Foot
# Motion Bone: RL_L_Finger42
# Motion Bone: RL_R_Clavicle
# Motion Bone: RL_R_UpperArm
# Motion Bone: RL_R_Forearm
# Motion Bone: RL_R_Hand
# Motion Bone: RL_R_Calf
# Motion Bone: RL_R_Foot
# Motion Bone: RL_Neck
# Motion Bone: RL_L_Forearm
# Motion Bone: RL_Spine01
# Motion Bone: RL_L_Hand
you can also follow this link
hereHope all goes well
Chris