AREA forums upgrade
Read more about the planned upgrade of our forums
  • 1/3
You are here: Forum Home / Autodesk® Maya® / Animation / Labels in the Maya Timeline ?
IMPORTANT ANNOUNCEMENT ABOUT AREA FORUMS
  RSS 2.0 ATOM  

Labels in the Maya Timeline ?
Rate this thread
 
65589
 
Permlink of this thread  
avatar
  • Total Posts: 8
  • Joined: 22 August 2006 03:40 PM

Does anyone know if there is a way to mark certain frames or certain regions of the maya timeline with labels.

Basically I want to be able to set a label at certain keyframes so that I can export this information for use in a third-party tool.

Any mel or python scripts out there that do this ?

Any ideas ?

Thanks



Replies: 0
avatar
  • ldunham1
  • Posted: 28 March 2012 04:08 AM

what information did you want to export? the start and end frames of the labels in the timeline?
you could have all the information wrapped in a nested python dictionary like so;

data { 1{'label''This is shot 001''start'1'end'10},
         
2{'label''This is shot 002''start'11'end'25},
         
3{'label''This is shot 003 - Needs Editing''start'26'end'50} }
         
print data[1]['label']

print data[2]['start']data[2]['end']

that data can be easily created/updated via a simple UI and exported, written in either in a text file, or depending on compatibility issues, into a string attr in a node.

Or am I getting the wrong end of the stick?



try pressing 'b'…
ldunham.blogspot.com

Replies: 1
/img/forum/light/default_avatar.png

Hi,

Thanks for the reply.

Yes this is exactly what I am looking to do.  And write the data out to a simple text file.

Should be pretty straightforward right?

Mike

Author: mikebellca

Replied: 28 March 2012 04:16 PM  
avatar
  • ldunham1
  • Posted: 30 March 2012 01:13 AM

yeah theres loads of possibilities depending on what your writing, how your reading etc.
If the pickup program uses python i’d wholeheartedly suggest using cPickle, by far the best method for this job, plus its fast.

try:
    
import cPickle as pickle
except
:
    
import pickle

# nested DICTIONARY
data 'one'{'label''This is shot 001''start'1'end'10},
         
'two'{'label''This is shot 002''start'11'end'25},
         
'three'{'label''This is shot 003 - Needs Editing''start'26'end'50} }

# write to file with cPickle/pickle (as binary)
def ld_writeDicts(filePath,dict):
    
f=open(filePath,'w')
    
newData pickle.dumps(dict1)
    
f.write(newData)
    
f.close()

ld_writeDicts('C:/Users/Lee/Desktop/test2.dta',data)



# read file decoding with cPickle/pickle (as binary)
def ld_readDicts(filePath):
    
f=open(filePath,'r')
    
data pickle.load(f)
    
f.close()
    return 
data

# return dict data to new dict
newDataDict ld_readDicts('C:/Users/Lee/Desktop/test2.dta')
# test nesting
print newDataDict['one']['label']

Otherwise, if the data needs to be user-friendly (readable without decoding) i’d suggest json. (you could just dump the info as a raw string, but json will arrange and indent, looking prettier)

import json

# nested DICTIONARY
data 'one'{'label''This is shot 001''start'1'end'10},
         
'two'{'label''This is shot 002''start'11'end'25},
         
'three'{'label''This is shot 003 - Needs Editing''start'26'end'50} }

# write to file with json encoding
def ld_writeDicts(filePath,dict):
    
f=open(filePath,'w')
    
newData json.dumps(dictsort_keys=Trueindent=4)
    
f.write(newData)
    
f.close()

ld_writeDicts('C:/test.dta',data)


# read file decoding with json
def ld_readDicts(filePath):
    
f=open(filePath,'r')
    
data json.loads(f.read())
    
f.close()
    return 
data

# return dict data to new dict
newDataDict ld_readDicts('C:/test.dta')
# test nesting
print newDataDict['one']['label']

again I would suggest cPickle, as it’ll support far more elementary data types other than dictionaries.



try pressing 'b'…
ldunham.blogspot.com

Replies: 0