|
|
clipka, I think I found an error!
#include <python3.3m/Python.h>
#include <iostream>
int main() {
int len;
Py_Initialize();
PyRun_SimpleString("import sys");
PyRun_SimpleString("sys.path.append(\".\")");
PyRun_SimpleString("import bpy");
PyRun_SimpleString("bpy.ops.wm.open_mainfile(filepath='/home/leonid/workspace/blender/files_blend/test_so.blend')");
//read blend-file
PyObject *pyModuleName = PyUnicode_FromString("bpy");
PyObject *pyModuleName1 = PyUnicode_FromString("bimport");
PyObject *pyModule = PyImport_Import(pyModuleName); // import Blender module
PyObject *pyModule1 = PyImport_Import(pyModuleName1); // import my module
with parser functions
PyObject *pyFunc = PyObject_GetAttrString(pyModule1,
"import_blender_scene");
PyObject *pyArgs = PyTuple_New(1);
PyTuple_SetItem(pyArgs, 0, pyModule);
PyObject *pyLen = PyObject_CallObject(pyFunc, pyArgs);
len = PyLong_AsLong(pyLen);
std::cout<<len<<std::endl; // Number of objects in scene (5)
Py_Finalize();
std::cout<<"Hello world!"<<std::endl; //After py_finalize!!!!
return 0;
}
Konsole:
read blend: /home/leonid/workspace/blender/files_blend/test_so.blend
5
Hello world!
------------------
(program exited with code: 0)
Now I will try to create classes! Thank you. Your support has helped me.
Post a reply to this message
|
|