trouble with cmds clip

12 views
Skip to first unread message

Benjam901

unread,
May 27, 2016, 5:21:23 AM5/27/16
to Python Programming for Autodesk Maya
Hello all,

I am having a bit of trouble with creating multiple clips and applying them to a character set.

What I am trying to achieve is to have multiple clips on one character set for animated props. 
The user would create their clips in the tool I have set up and then exporting the prop would create a character set for the prop in question.
I then create clips using the start and end times the user has provided.

Problem I am having is when the user has more than one clip I need to leave the keys on the timeline so I can extract them again I do this using:

def createCharSet(ns='', selectObj='vh'):
 
'''create character set'''
 char_name
='char_'+ns
 cmds
.select(str(selectObj),hi=1)
 
char = cmds.character(name=char_name)
 
return char

char_name= createCharSet(ns='test', selectObj='animated_prop')
cmds.clip(char_name, sc=1, name='clip_test',startTime=0,endTime=85, lo=1)
cmds.clip(char_name, sc=1, name='clip_test2',startTime=95,endTime=136, lo=1)


Using the lo=1 flag I get to keep the keys and make as many clips as I want....except using this flag offsets my animation in very weird ways and I am confused as to why this is happening. 
I have tried setting other flags such as allRelative, allAbsolute etc. to 0 but to no avail.

am I missing a flag or 2 that is helping me achieve this?

Cheers,

Ben

Benjam901

unread,
May 27, 2016, 11:20:33 AM5/27/16
to Python Programming for Autodesk Maya
Fear not for I found a workaround.

I made a clip of the entire timeline and then duplicated it and resetting the start & end points for each clip

char = cmds.character(name='char_')
fullMin
, fullMax = setAndReturnMinMax()
fullClip
= cmds.clip(char, sc=1, name='clipFull',startTime=fullMin, endTime=fullMax)
fullClipName
= fullClip[0]+'Source'

for clipName in propClipData:
 
# Extract all the info we need
 timeRange
= propClipData[clipName]['key_range']
 minKey
= int(timeRange.split(':')[0])
 maxKey
= int(timeRange.split(':')[1])
 
# Duplicate the clip
 dupeClip
= cmds.clip(char, name=fullClipName, d=1, sc=1, newName=clipName)
 cmds
.setAttr(dupeClip+'.startFrame', minKey)
 cmds
.setAttr(dupeClip+'.sourceStart', minKey)
 cmds
.setAttr(dupeClip+'.sourceEnd', maxKey)
 cmds
.clip(char, name=dupeClip+'Source', newName=clipName)
cmds
.clip(char, rm=1, name=fullClipName) # remove the full clip leaving only our proper clips

Reply all
Reply to author
Forward
0 new messages