Profile Picture

Scripted Bone Rotations Not Showing Up As Motion Or Motion Layer Key Frames

Posted By Lord Ashes 4 Years Ago
You don't have permission to rate!

Scripted Bone Rotations Not Showing Up As Motion Or Motion Layer Key...

Author
Message
Lord Ashes
Lord Ashes
Posted 4 Years Ago
View Quick Profile
Distinguished Member

Distinguished Member (20.8K reputation)Distinguished Member (20.8K reputation)Distinguished Member (20.8K reputation)Distinguished Member (20.8K reputation)Distinguished Member (20.8K reputation)Distinguished Member (20.8K reputation)Distinguished Member (20.8K reputation)Distinguished Member (20.8K reputation)Distinguished Member (20.8K reputation)

Group: Forum Members
Last Active: 3 Weeks Ago
Posts: 1.3K, Visits: 1.6K
As my introduction to Python scripting, I created a Python script to change the rotation of an Avatar's heard. I have the script working and when I apply it to an Avatar and play, the rotation is there. That is good.
However, the issue is that when I look at my timeline for the Avatar I don't see any key frames on the Transform layer (didn't expect any there since this is a head animation) but I also don't get any key frames on the Motion, Motion | Gesture, Motion | Motion Layer or Motion | Motion Layer | Head layer where I expected to find some keys to reflect the script added rotation.

As far as I can see, currently there is no evidence on the time line that a rotation should be applied to the head but the playback clearly shows one.

Is there something that I need to add to my script in order to update the key frames? Should my script be setting the bone rotation in a different way in order to produce key frames?

The current code that I am using is:


import RLPy
print("Get Avatar")
avatar = RLPy.RScene.GetSelectedObjects()[0]
print("Get Bones")
motion_bones = avatar.GetSkeletonComponent().GetMotionBones()
print("Get Head Bone")
bone = motion_bones[0]
for this_bone in motion_bones:
  if this_bone.GetName() == "RL_Head":
    bone = this_bone
    break
print("Create clip")
clip = avatar.GetSkeletonComponent().AddClip(RLPy.RGlobal.GetTime())
clip.SetLength(RLPy.RTime(150*1000))
print("Grab bone")
control = clip.GetControl("Layer", bone).GetDataBlock().GetControl("Rotation/RotationY")
print("Rotating...")
rotation_y = -45
frame = 0
for loop in range(16):
    print("Setting Rotation %d At Time Frame %d." %(rotation_y, frame))
    control.SetValue(RLPy.RTime(frame/60*1000, RLPy.kMilliseconds), rotation_y / 180 * RLPy.RMath.CONST_PI)
    rotation_y = rotation_y + 5
    frame = frame + 10
print("Done")


"We often compare ourselves to the U.S. and often they come out the best, but they only have the right to bear arms while we have the right to bare breasts"
Bowser and Blue, Busting The Breast
4u2ges
4u2ges
Posted 4 Years Ago
View Quick Profile
Distinguished Member

Distinguished Member (20.6K reputation)Distinguished Member (20.6K reputation)Distinguished Member (20.6K reputation)Distinguished Member (20.6K reputation)Distinguished Member (20.6K reputation)Distinguished Member (20.6K reputation)Distinguished Member (20.6K reputation)Distinguished Member (20.6K reputation)Distinguished Member (20.6K reputation)

Group: Forum Members
Last Active: 1 minute ago
Posts: 5.0K, Visits: 15.9K
I am not sure to call it a bug or not, but the keyframes would appear as soon as you make changes to any bone.
The easiest way, is on the first frame of the timeline select Motion Layer and click + to add a key.




Edited
4 Years Ago by 4u2ges
videodv
videodv
Posted 4 Years Ago
View Quick Profile
Distinguished Member

Distinguished Member (2.7K reputation)Distinguished Member (2.7K reputation)Distinguished Member (2.7K reputation)Distinguished Member (2.7K reputation)Distinguished Member (2.7K reputation)Distinguished Member (2.7K reputation)Distinguished Member (2.7K reputation)Distinguished Member (2.7K reputation)Distinguished Member (2.7K reputation)

Group: Forum Members
Last Active: Last Year
Posts: 342, Visits: 12.0K
Lord Ashes (10/3/2020)
As my introduction to Python scripting, I created a Python script to change the rotation of an Avatar's heard. I have the script working and when I apply it to an Avatar and play, the rotation is there. That is good.
However, the issue is that when I look at my timeline for the Avatar I don't see any key frames on the Transform layer (didn't expect any there since this is a head animation) but I also don't get any key frames on the Motion, Motion | Gesture, Motion | Motion Layer or Motion | Motion Layer | Head layer where I expected to find some keys to reflect the script added rotation.

As far as I can see, currently there is no evidence on the time line that a rotation should be applied to the head but the playback clearly shows one.

Is there something that I need to add to my script in order to update the key frames? Should my script be setting the bone rotation in a different way in order to produce key frames?

The current code that I am using is:


import RLPy
print("Get Avatar")
avatar = RLPy.RScene.GetSelectedObjects()[0]
print("Get Bones")
motion_bones = avatar.GetSkeletonComponent().GetMotionBones()
print("Get Head Bone")
bone = motion_bones[0]
for this_bone in motion_bones:
  if this_bone.GetName() == "RL_Head":
    bone = this_bone
    break
print("Create clip")
clip = avatar.GetSkeletonComponent().AddClip(RLPy.RGlobal.GetTime())
clip.SetLength(RLPy.RTime(150*1000))
print("Grab bone")
control = clip.GetControl("Layer", bone).GetDataBlock().GetControl("Rotation/RotationY")
print("Rotating...")
rotation_y = -45
frame = 0
for loop in range(16):
    print("Setting Rotation %d At Time Frame %d." %(rotation_y, frame))
    control.SetValue(RLPy.RTime(frame/60*1000, RLPy.kMilliseconds), rotation_y / 180 * RLPy.RMath.CONST_PI)
    rotation_y = rotation_y + 5
    frame = frame + 10
print("Done")


HI

Try putting this bit of code after the final loop and before you print "Done" and see if it helps.

#-- Update timeline --#     
RLPy.RGlobal.Stop()
RLPy.RGlobal.SetTime(RLPy.RGlobal.GetTime())

Chris


Lord Ashes
Lord Ashes
Posted 4 Years Ago
View Quick Profile
Distinguished Member

Distinguished Member (20.8K reputation)Distinguished Member (20.8K reputation)Distinguished Member (20.8K reputation)Distinguished Member (20.8K reputation)Distinguished Member (20.8K reputation)Distinguished Member (20.8K reputation)Distinguished Member (20.8K reputation)Distinguished Member (20.8K reputation)Distinguished Member (20.8K reputation)

Group: Forum Members
Last Active: 3 Weeks Ago
Posts: 1.3K, Visits: 1.6K

Try putting this bit of code after the final loop and before you print "Done" and see if it helps.
#-- Update timeline --#     
RLPy.RGlobal.Stop()
RLPy.RGlobal.SetTime(RLPy.RGlobal.GetTime())

Thanks for the suggestion but it did not help.

Here is a video of what is happening...





"We often compare ourselves to the U.S. and often they come out the best, but they only have the right to bear arms while we have the right to bare breasts"
Bowser and Blue, Busting The Breast
Edited
4 Years Ago by Lord Ashes
4u2ges
4u2ges
Posted 4 Years Ago
View Quick Profile
Distinguished Member

Distinguished Member (20.6K reputation)Distinguished Member (20.6K reputation)Distinguished Member (20.6K reputation)Distinguished Member (20.6K reputation)Distinguished Member (20.6K reputation)Distinguished Member (20.6K reputation)Distinguished Member (20.6K reputation)Distinguished Member (20.6K reputation)Distinguished Member (20.6K reputation)

Group: Forum Members
Last Active: 1 minute ago
Posts: 5.0K, Visits: 15.9K
HI

Try putting this bit of code after the final loop and before you print "Done" and see if it helps.

#-- Update timeline --#     
RLPy.RGlobal.Stop()
RLPy.RGlobal.SetTime(RLPy.RGlobal.GetTime())

Chris


Thanks Chris, worked for me, just had to restart iClone.
Interesting, if you run the script even once, without those 2 lines in freshly opened iClone, then adding them thereafter does not make any difference.
You have to restart iClone and run script with 2 lines added first, then it would work.




Edited
4 Years Ago by 4u2ges
videodv
videodv
Posted 4 Years Ago
View Quick Profile
Distinguished Member

Distinguished Member (2.7K reputation)Distinguished Member (2.7K reputation)Distinguished Member (2.7K reputation)Distinguished Member (2.7K reputation)Distinguished Member (2.7K reputation)Distinguished Member (2.7K reputation)Distinguished Member (2.7K reputation)Distinguished Member (2.7K reputation)Distinguished Member (2.7K reputation)

Group: Forum Members
Last Active: Last Year
Posts: 342, Visits: 12.0K
Lord Ashes (10/3/2020)

Try putting this bit of code after the final loop and before you print "Done" and see if it helps.
#-- Update timeline --#     
RLPy.RGlobal.Stop()
RLPy.RGlobal.SetTime(RLPy.RGlobal.GetTime())

Thanks for the suggestion but it did not help.

Here is a video of what is happening...





Hi Lord Ashes

In order to see the keys on the timeline you need to play the sequence this will update the timeline if you just scroll the timeline it will not update the keys, the script addition that I included will do this for you.

Chris.
4u2ges
4u2ges
Posted 4 Years Ago
View Quick Profile
Distinguished Member

Distinguished Member (20.6K reputation)Distinguished Member (20.6K reputation)Distinguished Member (20.6K reputation)Distinguished Member (20.6K reputation)Distinguished Member (20.6K reputation)Distinguished Member (20.6K reputation)Distinguished Member (20.6K reputation)Distinguished Member (20.6K reputation)Distinguished Member (20.6K reputation)

Group: Forum Members
Last Active: 1 minute ago
Posts: 5.0K, Visits: 15.9K
This whole thing with timeline update is still buggy. I know at least one way to mess it up so that nothing would work with timeline update regardless... until iClone restart.
I am sure there are more ways to screw it up, whenever I have more time I'll do a thorough testing.




Lord Ashes
Lord Ashes
Posted 4 Years Ago
View Quick Profile
Distinguished Member

Distinguished Member (20.8K reputation)Distinguished Member (20.8K reputation)Distinguished Member (20.8K reputation)Distinguished Member (20.8K reputation)Distinguished Member (20.8K reputation)Distinguished Member (20.8K reputation)Distinguished Member (20.8K reputation)Distinguished Member (20.8K reputation)Distinguished Member (20.8K reputation)

Group: Forum Members
Last Active: 3 Weeks Ago
Posts: 1.3K, Visits: 1.6K

Hi Lord Ashes
In order to see the keys on the timeline you need to play the sequence this will update the timeline if you just scroll the timeline it will not update the keys, the script addition that I included will do this for you.
Chris.


Thanks. I will give that a try.



"We often compare ourselves to the U.S. and often they come out the best, but they only have the right to bear arms while we have the right to bare breasts"
Bowser and Blue, Busting The Breast
Lord Ashes
Lord Ashes
Posted 4 Years Ago
View Quick Profile
Distinguished Member

Distinguished Member (20.8K reputation)Distinguished Member (20.8K reputation)Distinguished Member (20.8K reputation)Distinguished Member (20.8K reputation)Distinguished Member (20.8K reputation)Distinguished Member (20.8K reputation)Distinguished Member (20.8K reputation)Distinguished Member (20.8K reputation)Distinguished Member (20.8K reputation)

Group: Forum Members
Last Active: 3 Weeks Ago
Posts: 1.3K, Visits: 1.6K
I have tried both suggestions:
1. To put the stop code at the end. Restart iClone and then run script.
2. To play after running the script.
Neither solution worked for me. In both cases I still not get any key frames or motion indicating that an animation is applied.

BTW, I also discovered that the Play() function does not seem to respect the time provided. The Play() function is supposed to take a start and end time parameter but when I set it for a time interval that should be 150 frames the it plays the whole project time anyway. I am fairly sure that I am providing the correct values since I use the same values to build the animation.



"We often compare ourselves to the U.S. and often they come out the best, but they only have the right to bear arms while we have the right to bare breasts"
Bowser and Blue, Busting The Breast
videodv
videodv
Posted 4 Years Ago
View Quick Profile
Distinguished Member

Distinguished Member (2.7K reputation)Distinguished Member (2.7K reputation)Distinguished Member (2.7K reputation)Distinguished Member (2.7K reputation)Distinguished Member (2.7K reputation)Distinguished Member (2.7K reputation)Distinguished Member (2.7K reputation)Distinguished Member (2.7K reputation)Distinguished Member (2.7K reputation)

Group: Forum Members
Last Active: Last Year
Posts: 342, Visits: 12.0K
Hi Lord Ashes

Here is the play example as I ran your original script on my system.



Chris

Edited
4 Years Ago by videodv



Reading This Topic