Skip to content

Instantly share code, notes, and snippets.

@splinecraft
Created September 7, 2016 18:26
Show Gist options
  • Save splinecraft/dc4eb744603eaece3602c5558f6840ea to your computer and use it in GitHub Desktop.
Save splinecraft/dc4eb744603eaece3602c5558f6840ea to your computer and use it in GitHub Desktop.
Query Maya timeline selection
# Method 1
from pymel.core import *
slider = mel.eval('$tmpVar=$gPlayBackSlider')
sliderFrames = ''.join([c for c in timeControl(slider, q=1, rng=1) if c in '1234567890:'])
sliderStart = int(sliderFrames.split(":")[0])
sliderEnd = int(sliderFrames.split(":")[1])
#-----------------------------------------------------------------------------------------#
# Method 2
import pymel.core as pm
tc = pm.lsUI(type='timeControl')[0]
time_selected = pm.timeControl(tc, ra=True, q=True)
# Result: [6.0, 15.0] #
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment