Skip to content

Commit

Permalink
Move omx from AL_maya2
Browse files Browse the repository at this point in the history
  • Loading branch information
Miguel Gao committed Oct 10, 2023
0 parents commit b8faee6
Show file tree
Hide file tree
Showing 66 changed files with 6,327 additions and 0 deletions.
81 changes: 81 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]

# C extensions
*.so

# Distribution / packaging
.Python
env/
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
.sonar/
*.egg-info/
.installed.cfg
*.egg
.settings/
.scannerwork

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.coverage
.coverage.*
.cache
*nosetests.xml
coverage.xml
*,cover

# Translations
*.mo
*.pot

# Django stuff:
*.log

# Sphinx documentation
docs/_build/

# PyBuilder
target/

# Eclipse
.project
.cproject
*.prefs
.pydevproject

# PyCharm
.idea

# Build
/META-INF/
/build.properties
build/
.ropeproject/

# VSCode
.vscode

# Merge & Rebase temp file
.orig
7 changes: 7 additions & 0 deletions AL/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
"""
This file will not be used. It is a proxy for the real AL.__init__.py declared in PythonLibs source code
"""
try:
__import__("pkg_resources").declare_namespace(__name__)
except:
pass
51 changes: 51 additions & 0 deletions AL/omx/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# Copyright (C) Animal Logic Pty Ltd. All rights reserved.

"""
OMX is a thin wrapper around Maya OM2.
OMX's goal is to make OM2 more user-friendly but still retain the API's performance.
Main entry points are:
:py:func:`omx.createDagNode` and :py:func:`omx.createDGNode` which return instances of :py:class:`omx.XNode`
See :doc:`/topics/omx` for more information.
"""
from ._xplug import XPlug # NOQA: F401
from ._xnode import XNode # NOQA: F401
from ._xmodifier import (
createDagNode,
createDGNode,
doIt,
currentModifier,
newModifierContext,
newModifier,
newAnimCurveModifier,
commandModifierContext,
XModifier,
queryTrackedNodes,
TrackCreatedNodes,
) # NOQA: F401

try:
from . import _xcommand as _

_.XCommand.ensureLoaded()
except Exception as e:
print(f"Loading AL_OMXCommand: {str(e)}: omx might not function as intended!")

__all__ = [
"createDagNode",
"createDGNode",
"doIt",
"currentModifier",
"newModifierContext",
"newModifier",
"newAnimCurveModifier",
"commandModifierContext",
"XPlug",
"XNode",
"XModifier",
"queryTrackedNodes",
"TrackCreatedNodes",
]
54 changes: 54 additions & 0 deletions AL/omx/_xcommand.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# Copyright (C) Animal Logic Pty Ltd. All rights reserved.

import logging
from maya import cmds
from maya.api import OpenMaya as om2
from AL.maya2.omx import _xmodifier

logger = logging.getLogger(__name__)


class XCommand(om2.MPxCommand):

"""Dynamic command plugin called by createAL_Command
"""

PLUGIN_CMD_NAME = "AL_OMXCommand"
_CMD_PLUGIN_LOADED = False

def __init__(self):
om2.MPxCommand.__init__(self)
logger.debug("%r() instanced created", self)
self._modifiers = _xmodifier.getAndClearModifierStack()
logger.debug(
"%r() instanced created got %i modifiers", self, len(self._modifiers)
)

@staticmethod
def creator():
return XCommand()

def isUndoable(self):
return True

def doIt(self, argList): # NOQA
logger.debug("%r.doIt() called with %i modifiers", self, len(self._modifiers))
for mod in self._modifiers:
mod.doIt()

def redoIt(self):
logger.debug("%r.redoIt() called", self)
for mod in self._modifiers:
mod.doIt()

def undoIt(self):
logger.debug("%r.undoIt() called", self)
for mod in reversed(self._modifiers):
mod.undoIt()

@classmethod
def ensureLoaded(cls):
if cls._CMD_PLUGIN_LOADED:
return
cmds.loadPlugin(cls.PLUGIN_CMD_NAME, quiet=True)
cls._CMD_PLUGIN_LOADED = True
Loading

0 comments on commit b8faee6

Please sign in to comment.