Created
June 13, 2021 00:35
-
-
Save mclavan/8f0860d7f389d90ece3b6847f1e4d51a to your computer and use it in GitHub Desktop.
coding session 6/12/21
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pymel.core as pm | |
# pm.Callback(get_hand_icon, min, max, dv) | |
win_width = 200 | |
hand_icon = '' | |
finger_joint = '' | |
finger_attr = 'index_curl' | |
def gui(): | |
global hand_txt, joint_txt | |
win = pm.window(w=win_width, h=200, title='SDK Copy') | |
main_layout = pm.columnLayout() | |
pm.button(w=win_width, label='Hand', command=pm.Callback(get_hand_icon)) | |
hand_txt = pm.text(w=win_width, label='none', h=25) | |
pm.button(w=win_width, label='Joint', command=pm.Callback(get_root_joint)) | |
joint_txt = pm.text(w=win_width, label='none', h=25) | |
pm.button(w=win_width, label='Do It', command=pm.Callback(create_finger_sdk)) | |
win.show() | |
def get_hand_icon(): | |
global hand_icon | |
hand_icon = pm.ls(sl=True)[0] | |
hand_txt.setLabel('Captured: ' + hand_icon) | |
print('Captured: ' + hand_icon) | |
def get_root_joint(): | |
global finger_joint | |
finger_joint = pm.ls(sl=True)[0] | |
finger_joint.rx.get() | |
finger_joint.rx.set(0) | |
joint_txt.setLabel('Captured: ' + finger_joint) | |
joint_txt.getLabel() | |
print('Captured: ' + finger_joint) | |
def create_finger_sdk(): | |
pieces = finger_joint.split('_') # ['lt', 'index', '01', 'bind'] | |
ori = pieces[0] | |
name = pieces[1] | |
pm.setDrivenKeyframe(['{0}_{1}_01_bind.rotateZ'.format(ori, name)], value=-80, currentDriver='{0}.{1}'.format(hand_icon, finger_attr), driverValue=10) | |
pm.setDrivenKeyframe(['{0}_{1}_01_bind.rotateZ'.format(ori, name)], value=0, currentDriver='{0}.{1}'.format(hand_icon, finger_attr), driverValue=0) | |
pm.setDrivenKeyframe(['{0}_{1}_01_bind.rotateZ'.format(ori, name)], value=30, currentDriver='{0}.{1}'.format(hand_icon, finger_attr), driverValue=-10) | |
pm.setDrivenKeyframe(['{0}_{1}_02_bind.rotateZ'.format(ori, name)], value=-80, currentDriver='{0}.{1}'.format(hand_icon, finger_attr), driverValue=10) | |
pm.setDrivenKeyframe(['{0}_{1}_02_bind.rotateZ'.format(ori, name)], value=0, currentDriver='{0}.{1}'.format(hand_icon, finger_attr), driverValue=0) | |
pm.setDrivenKeyframe(['{0}_{1}_02_bind.rotateZ'.format(ori, name)], value=30, currentDriver='{0}.{1}'.format(hand_icon, finger_attr), driverValue=-10) | |
pm.setDrivenKeyframe(['{0}_{1}_03_bind.rotateZ'.format(ori, name)], value=-80, currentDriver='{0}.{1}'.format(hand_icon, finger_attr), driverValue=10) | |
pm.setDrivenKeyframe(['{0}_{1}_03_bind.rotateZ'.format(ori, name)], value=0, currentDriver='{0}.{1}'.format(hand_icon, finger_attr), driverValue=0) | |
pm.setDrivenKeyframe(['{0}_{1}_03_bind.rotateZ'.format(ori, name)], value=30, currentDriver='{0}.{1}'.format(hand_icon, finger_attr), driverValue=-10) | |
gui() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment