Hey guys, how are you doing?
I'm trying compile some scripts with Cython and Maya and I've some doubts.
How can I declare the OpenMaya types on cpdef?
My setup script is this:
from setuptools import setup, Extension
from Cython.Build import cythonize
import os
def _script_path(module_name):
return os.path.join(os.path.dirname(__file__), "src",
module_name).replace("//", "/")
setup(
name="vzUtils",
ext_modules=cythonize(
Extension("vzUtils",
language="c++",
sources=[_script_path("vzUtils.pyx")],
include_dirs=[
"C:/Program
Files/Autodesk/Maya2019/Python/Lib/site-packages",
"C:/Program Files/Autodesk/Maya2019/include",
os.path.join(os.path.dirname(__file__),
"src").replace("//", "/")
],
libraries=[
"Foundation",
"OpenMaya",
"OpenMayaUI",
"OpenMayaAnim",
"OpenMayaFX",
"OpenMayaRender",
"Image"
],
library_dirs=[
"C:/Program Files/Autodesk/Maya2019/lib",
"C:/Program Files/Autodesk/Maya2019/Python/DLLs"
])
)
)
And my script test is this:
# distiutils: Language=c++
from maya import OpenMaya
cpdef list_nodes_connections(node, list node_list):
if node.isNull():
return
node_plugs = OpenMaya.MPlugArray()
fn = OpenMaya.MFnDependencyNode(node)
if fn.typeName() in ["mesh", "polyCurve"]:
return
fn.getConnections(node_plugs)
cdef int i = 0
cdef int k = 0
for i in range(node_plugs.length()):
plugs_connected = OpenMaya.MPlugArray()
node_plugs[i].connectedTo(plugs_connected, True, False)
for k in range(plugs_connected.length()):
list_nodes_connections(plugs_connected[k].node(), node_list)
if fn.name() not in node_list:
node_list.append(fn.name())
I compile this script successfully but the Maya doesn't import them. Maya
said is not possible to import the DLL...
I tried to declare the Maya's type and resulted in a compilation error.
Cython said that MObject is unknown type:
cpdef list_nodes_connections(MObject nodes, list node_list):
Have you any idea to fix these errors? How the best practice to use Cython
and Maya? Must I recompile for each Maya's version linking like C++
plug-ins?
Regards,
Gabriel Valderramos
--
You received this message because you are subscribed to the Google Groups
"Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/python_inside_maya/dc8e094c-b78a-4077-b7e1-1d9af18f5ae7%40googlegroups.com.