3
0

set_defaults.py 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. # coding:utf-8
  2. #!/usr/bin/python
  3. #
  4. # Copyright (c) Contributors to the Open 3D Engine Project.
  5. # For complete copyright and license terms please see the LICENSE at the root of this distribution.
  6. #
  7. # SPDX-License-Identifier: Apache-2.0 OR MIT
  8. #
  9. #
  10. # -------------------------------------------------------------------------
  11. """
  12. Module Documentation:
  13. DccScriptingInterface:: SDK//maya//scripts//set_pref_defaults.py
  14. This module manages a predefined set of prefs for maya
  15. """
  16. # -------------------------------------------------------------------------
  17. # -- Standard Python modules
  18. import os
  19. import sys
  20. import logging as _logging
  21. # -- External Python modules
  22. # none
  23. # -- DCCsi Extension Modules
  24. import DccScriptingInterface.azpy
  25. from DccScriptingInterface.azpy.constants import *
  26. # -- maya imports
  27. import maya.cmds as mc
  28. import maya.mel as mm
  29. # -------------------------------------------------------------------------
  30. # -------------------------------------------------------------------------
  31. # global scope
  32. from DccScriptingInterface.Tools.DCC.Maya import _PACKAGENAME
  33. _MODULENAME = f'{_PACKAGENAME}.set_defaults'
  34. _LOGGER = _logging.getLogger(_MODULENAME)
  35. _LOGGER.info(f'Initializing: {_MODULENAME}')
  36. from DccScriptingInterface.globals import *
  37. # -------------------------------------------------------------------------
  38. # -------------------------------------------------------------------------
  39. def set_defaults(units='meter'):
  40. """This method will make defined settings changes to Maya prefs,
  41. to better configure maya to work with Lumberyard"""
  42. # To Do: make this data-driven env/settings, game teams should be able
  43. # to opt out and/or set their prefered configuration.
  44. _LOGGER.debug('set_defaults_lumberyard() fired')
  45. # set up default units ... this should be moved to bootstrap config
  46. _LOGGER.info('Default, 1 Linear Game Unit in Lumberyard == 1 Meter'
  47. ' in Maya content. Setting default linear units to Meters'
  48. ' (user can change to other units in the preferences)')
  49. result = mc.currentUnit(linear=units)
  50. # set up grid defaults
  51. _LOGGER.info('Setting Grid defaults, to match default unit scale.'
  52. '(user can change grid config manually')
  53. try:
  54. mc.grid(size=32, spacing=1, divisions=10)
  55. except Exception as e:
  56. _LOGGER.warning('{0}'.format(e))
  57. # viewFit
  58. _LOGGER.info('Changing default mc.viewFit')
  59. try:
  60. mc.viewFit()
  61. except Exception as e:
  62. _LOGGER.warning('{0}'.format(e))
  63. # some mel commands
  64. _LOGGER.info('Changing sersp camera clipping planes')
  65. try:
  66. mm.eval(str(r'setAttr "perspShape.nearClipPlane" 0.01;'))
  67. mm.eval(str(r'setAttr "perspShape.farClipPlane" 1000;'))
  68. except Exception as e:
  69. _LOGGER.warning('{0}'.format(e))
  70. # set up fixPaths
  71. _LOGGER.info('~ Setting up fixPaths in default scene')
  72. return 0
  73. # -------------------------------------------------------------------------