本文整理汇总了Python中maya.cmds.currentUnit方法的典型用法代码示例。如果您正苦于以下问题:Python cmds.currentUnit方法的具体用法?Python cmds.currentUnit怎么用?Python cmds.currentUnit使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类maya.cmds
的用法示例。
在下文中一共展示了cmds.currentUnit方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: getFrameRate
# 需要导入模块: from maya import cmds [as 别名]
# 或者: from maya.cmds import currentUnit [as 别名]
def getFrameRate():
'''
Return an int of the current frame rate
'''
currentUnit = mc.currentUnit(query=True, time=True)
if currentUnit == 'film':
return 24
if currentUnit == 'show':
return 48
if currentUnit == 'pal':
return 25
if currentUnit == 'ntsc':
return 30
if currentUnit == 'palf':
return 50
if currentUnit == 'ntscf':
return 60
if 'fps' in currentUnit:
return int(currentUnit.substitute('fps',''))
return 1
示例2: getDistanceInMeters
# 需要导入模块: from maya import cmds [as 别名]
# 或者: from maya.cmds import currentUnit [as 别名]
def getDistanceInMeters():
unit = mc.currentUnit(query=True, linear=True)
if unit == 'mm':
return 1000
elif unit == 'cm':
return 100
elif unit == 'km':
return 0.001
elif unit == 'in':
return 39.3701
elif unit == 'ft':
return 3.28084
elif unit == 'yd':
return 1.09361
elif unit == 'mi':
return 0.000621371
return 1
示例3: BT_SetUnits
# 需要导入模块: from maya import cmds [as 别名]
# 或者: from maya.cmds import currentUnit [as 别名]
def BT_SetUnits():
if cmds.currentUnit(q = True, linear = True) != "cm":
cmds.currentUnit(linear = "cm")
return True
return False
示例4: dpCheckLinearUnit
# 需要导入模块: from maya import cmds [as 别名]
# 或者: from maya.cmds import currentUnit [as 别名]
def dpCheckLinearUnit(self, origRadius, defaultUnit="centimeter", *args):
""" Verify if the Maya linear unit is in Centimeter.
Return the radius to the new unit size.
WIP!
Changing to shapeSize cluster setup
"""
newRadius = origRadius
# newRadius = 1
# linearUnit = cmds.currentUnit(query=True, linear=True, fullName=True)
# # centimeter
# if linearUnit == defaultUnit:
# newRadius = origRadius
# elif linearUnit == "meter":
# newRadius = origRadius*0.01
# elif linearUnit == "millimeter":
# newRadius = origRadius*10
# elif linearUnit == "inch":
# newRadius = origRadius*0.393701
# elif linearUnit == "foot":
# newRadius = origRadius*0.032808
# elif linearUnit == "yard":
# newRadius = origRadius*0.010936
return newRadius
#@utils.profiler
示例5: set_fps
# 需要导入模块: from maya import cmds [as 别名]
# 或者: from maya.cmds import currentUnit [as 别名]
def set_fps(fps = None):
fps_string = "pal"
if fps == 25:
fps_string = "pal"
if fps == 24:
fps_string = "film"
if fps == 30:
fps_string = "ntsc"
cmds.currentUnit(t=fps_string)
示例6: initializeGL
# 需要导入模块: from maya import cmds [as 别名]
# 或者: from maya.cmds import currentUnit [as 别名]
def initializeGL(self):
#scene measure units
unit = cmds.currentUnit(q=1, linear=1)
if unit == "m":
self.unit = float(self.unit) * 100.0
self.glFT = OpenMayaRender.MHardwareRenderer.theRenderer().glFunctionTable()
示例7: _currentTimeUnit
# 需要导入模块: from maya import cmds [as 别名]
# 或者: from maya.cmds import currentUnit [as 别名]
def _currentTimeUnit(cls):
""" Returns the current time unit name. See MayaScene._timeUnitToFPS to map this value
to real world fps.
:return: The name of the current fps
"""
return cmds.currentUnit(q=True, time=True)
示例8: setAnimationFPS
# 需要导入模块: from maya import cmds [as 别名]
# 或者: from maya.cmds import currentUnit [as 别名]
def setAnimationFPS(self, fps, changeType=constants.FPSChangeType.Seconds, callback=None):
""" Updates the scene's fps to the provided value and scales existing keys as specified.
StudioMax Note: If you have any code that you need to run after changing the fps and plan to use it in
3dsMax you will need to pass that code into the callback argument.
Maya Note: Maya only supports specific fps settings. If you provide it with a value it doesn't understand,
it will be set to the closest matching value. See MayaScene._timeUnitToFPS for valid values.
:param fps: The FPS value to set.
:param changeType: <constants.FPSChangeType> Defaults to constants.FPSChangeType.Frames
:param callback: <funciton> Code called after the fps is changed.
:return: bool success
"""
# Maya doesn't appear to allow you to set the fps to a specific value,
# so we attempt to find a exact match in our _timeUnitToConst dictonary
name = self._timeUnitToConst.get(fps)
if not name:
# If there isn't a exact match, find the value closest to the requested fps.
closest = min(self._timeUnitToConst, key=lambda x: abs(x - fps))
name = self._timeUnitToConst[closest]
# Only update the fps if the value is different
if name != self._currentTimeUnit():
# Only update animation if Seconds is specified
updateAnimation = changeType == constants.FPSChangeType.Seconds
cmds.currentUnit(time=name, updateAnimation=updateAnimation)
if callback:
callback()
return True
示例9: reset_frame_range
# 需要导入模块: from maya import cmds [as 别名]
# 或者: from maya.cmds import currentUnit [as 别名]
def reset_frame_range():
"""Set frame range to current asset"""
shot = api.Session["AVALON_ASSET"]
shot = io.find_one({"name": shot, "type": "asset"})
try:
frame_start = shot["data"].get(
"frameStart",
# backwards compatibility
shot["data"].get("edit_in")
)
frame_end = shot["data"].get(
"frameEnd",
# backwards compatibility
shot["data"].get("edit_out")
)
except KeyError:
cmds.warning("No edit information found for %s" % shot["name"])
return
fps = {15: 'game',
24: 'film',
25: 'pal',
30: 'ntsc',
48: 'show',
50: 'palf',
60: 'ntscf',
23.98: '23.976fps',
23.976: '23.976fps',
29.97: '29.97fps',
47.952: '47.952fps',
47.95: '47.952fps',
59.94: '59.94fps',
44100: '44100fps',
48000: '48000fps'
}.get(float(api.Session.get("AVALON_FPS", 25)), "pal")
cmds.currentUnit(time=fps)
cmds.playbackOptions(minTime=frame_start)
cmds.playbackOptions(maxTime=frame_end)
cmds.playbackOptions(animationStartTime=frame_start)
cmds.playbackOptions(animationEndTime=frame_end)
cmds.playbackOptions(minTime=frame_start)
cmds.playbackOptions(maxTime=frame_end)
cmds.currentTime(frame_start)