POV-Ray : Newsgroups : povray.binaries.programming : My idea: Developers need tips! Help me, please! : Re: My idea: Developers need tips! Help me, please! Server Time
20 Apr 2024 04:14:14 EDT (-0400)
  Re: My idea: Developers need tips! Help me, please!  
From: LanuHum
Date: 13 Sep 2016 10:35:00
Message: <web.57d80d60397eea9f7a3e03fe0@news.povray.org>
clipka <ano### [at] anonymousorg> wrote:
> Am 12.09.2016 um 22:13 schrieb LanuHum:
> > "LanuHum" <Lan### [at] yandexru> wrote:
> >>
> >> We will look for errors. :))))
> >
> > :(
> > If I uncommented Py_Finalize(), application crash when the command Py_Finalize()
> > run. If I do not use the import of bpy, the application lives
>
> Have you finished your other homework yet?
>

No. To learn your lesson, I started from scratch. I started all over again.
I wrote a single function.
The function must import the module, clean it and write "Hello World".

#include <python3.3m/Python.h>
#include <iostream>

int main() {
    Py_Initialize();
    PyRun_SimpleString("import sys");
    PyRun_SimpleString("sys.path.append(\".\")");
    PyObject *pyModuleName = PyUnicode_FromString("bimport");
    PyObject *pyModule = PyImport_Import(pyModuleName);
    Py_DECREF(pyModuleName);
    Py_DECREF(pyModule);
    Py_Finalize();
    std::cout<<"Hello world!";
    return 0;
}

The "bimport" module is only one row : import bpy

make and run.

Konsole wrote:

Blender quit
------------------
(program exited with code: 0)
Press return to continue...

Where is the "Hello World"?

I can rearrange some places line:

    Py_DECREF(pyModule);
    Py_DECREF(pyModuleName);

same result.

There is also need classes? In my opinion, it is a bug, and need a new idea.


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.