Skip to content

Commit

Permalink
Merge pull request #21 from yantor3d/rporter/MDGModifier
Browse files Browse the repository at this point in the history
Implement DGModifier
  • Loading branch information
mottosso authored Jun 6, 2021
2 parents 8345f79 + c4c58bd commit 86cc176
Show file tree
Hide file tree
Showing 8 changed files with 1,221 additions and 3 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,6 @@
build/**
tmp/*
*.pyc
MFn.Types.inl
MFn.Types.inl
devkit.tgz
devkitBase
36 changes: 36 additions & 0 deletions Dockerfile.2022
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# Build locally for Linux on any platform, e.g. Windows
FROM mottosso/maya:2022

RUN yum install centos-release-scl -y && \
yum install devtoolset-7 bc -y

# Download devkit
ENV DEVKIT_LOCATION=/root/devkitBase
ENV DEVKIT "https://autodesk-adn-transfer.s3.us-west-2.amazonaws.com/ADN%20Extranet/M%26E/Maya/devkit%202022/Autodesk_Maya_2022_DEVKIT_Linux.tgz"
RUN wget $DEVKIT -O "/root/devkit.tgz" && \
tar -xvf /root/devkit.tgz $pwd

# Setup Test Environment
RUN mayapy -m pip install --user \
nose==1.3.7 \
nose-exclude==0.5.0 \
coverage==5.5 \
flaky==3.7.0 \
six==1.16.0 \
sphinx==1.8.5 \
sphinxcontrib-napoleon==0.7

# Since 2019, this sucker throws an
# unnecessary warning if not declared.
RUN mkdir -p /var/tmp/runtime-root
ENV XDG_RUNTIME_DIR /var/tmp/runtime-root
ENV MAYA_DISABLE_ADP 1

# The local /build directory
ENV PYTHONPATH=/workspace/build

WORKDIR /workspace

COPY docker_entrypoint.sh /usr/bin/entrypoint.sh
RUN chmod +x /usr/bin/entrypoint.sh
ENTRYPOINT [ "/usr/bin/entrypoint.sh" ]
4 changes: 4 additions & 0 deletions scripts/parse_header.py
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,10 @@ def filter_header_lines(class_name, lines):
skip_next_statement = True
continue

# OPENMAYA_PRIVATE appears to aways be at the endo f a header
if line.startswith('OPENMAYA_PRIVATE'):
break

try:
# Remove trailing comments
line = line[:line.index('//')].strip()
Expand Down
521 changes: 521 additions & 0 deletions src/MDGModifier.inl

Large diffs are not rendered by default.

6 changes: 5 additions & 1 deletion src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,14 @@
#include <maya/MColor.h>
#include <maya/MDataBlock.h>
#include <maya/MDataHandle.h>
#include <maya/MDGModifier.h>
#include <maya/MDistance.h>
#include <maya/MDagPath.h>
#include <maya/MEulerRotation.h>
#include <maya/MFn.h>
#include <maya/MIntArray.h>
#include <maya/MMatrix.h>
#include <maya/MNodeClass.h>
#include <maya/MObjectHandle.h>
#include <maya/MPoint.h>
#include <maya/MPlug.h>
Expand All @@ -43,6 +45,7 @@

#include "util/atov.hpp"
#include "util/plug.hpp"
#include "util/obj.hpp"

#define STRINGIFY(x) #x
#define MACRO_STRINGIFY(x) STRINGIFY(x)
Expand All @@ -63,10 +66,11 @@ PYBIND11_MODULE(cmdc, m) {
)pbdoc";

#include "Math.inl"
#include "MDagPath.inl"
#include "MDGModifier.inl"
#include "MFn.inl"
#include "Types.inl"
#include "MObject.inl"
#include "MDagPath.inl"
#include "MFnDependencyNode.inl"
#include "MFnDagNode.inl"
#include "MBoundingBox.inl"
Expand Down
16 changes: 16 additions & 0 deletions src/util/obj.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
namespace validate {
inline void is_not_null(MObject &o, std::string error_message) {
if (o.isNull()) {
throw std::invalid_argument(error_message.c_str());
}
}

inline void has_fn(MObject &o, MFn::Type type, std::string error_message) {
if (!o.hasFn(type)) {
MString msg(error_message.c_str());
msg.format(msg, o.apiTypeStr());

throw pybind11::type_error(msg.asChar());
}
}
}
25 changes: 24 additions & 1 deletion tests/__init__.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,36 @@
from maya import standalone, cmds


import cmdc


def setup():
standalone.initialize()



def new_scene():
cmds.file(new=True, force=True)


def teardown():
standalone.uninitialize()
standalone.uninitialize()


def assert_equals(expected, actual, error_message):
if isinstance(expected, float):
assert abs(expected - actual) <= 1e-5, error_message
else:
assert expected == actual, error_message


def as_obj(arg):
"""Return the Maya Object for the given node."""

return cmdc.SelectionList().add(arg).getDependNode(0)


def as_plug(arg):
"""Return the Maya Plug for the given plug."""

return cmdc.SelectionList().add(arg).getPlug(0)
Loading

0 comments on commit 86cc176

Please sign in to comment.