On 20/07/2015 at 11:21, xxxxxxxx wrote:
I'm starting to write concept for c4dtoa api py module ... i have small experience of py-binding with several projects(not for c4d)
Will post as text code. Lets start, small dirty code
i stack with BaseMaterial in c4dtoa.pyx. I still don't understand some things in cython
build.bat :
set MSSdk=1
set DISTUTILS_USE_SDK=1
call "C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\bin\x86_amd64\vcvarsx86_amd64.bat"
python.exe setup.py build_ext --inplace
pause
setup.py
# -*- coding: utf-8 -*-
from distutils.core import setup
from Cython.Build import cythonize
setup(ext_modules = cythonize(
"c4dtoa.pyx", # our Cython sourc
sources=["aGetNode.cpp"], # additional source file(s)
language="c++", # generate C++ code
))
c4dtoa.pyx
# -*- coding: utf-8 -*-
cdef extern from "c4d_basematerial.h":
ctypedef struct BaseMaterial:
pass
ctypedef void* BaseMaterial
cdef extern from "aGetNode.h":
void aGetNode(BaseMaterial* material)
def a_Get_Node(material) :
print "true"
cdef BaseMaterial material
aGetNode(&material)
aGetNode.cpp
#include "c4d.h"
#include "aGetNode.h"
#define C4DAI_SNMATERIAL_SHADER_NODE 202
void C4DTOA::aGetNode(BaseMaterial * material)
{
GePrint("Init");
if(!material) return FALSE;
GePrint("Init mat");
BaseContainer* bc = material->GetDataInstance();
BaseLink* bl = bc->GetBaseLink(C4DAI_SNMATERIAL_SHADER_NODE);
if (bl)
{
GvNode* bl2d = reinterpret_cast<GvNode*>(bl->GetLink(material->GetDocument()));
if (bl2d)
{
BaseContainer* bca = bl2d->GetOpContainerInstance();
}
else
GePrint("No link");
}
}
aGetNode.h
#include "c4d.h"
#include "c4d_basematerial.h"
namespace c4dtoa {
class C4DTOA {
public:
virtual void aGetNode(BaseMaterial* material);
};
}