I'm writing a plugin that imports, processes and exports 3d files (whatever cinema4d supports). It has two way of working:
I wanted to keep the code in modules, storing the first part in a scene_exporter.py and the second one in object_exporter.py and here comes the problems. I don't know if it's because the plugin is in a .pyp file, but the import just doesn't work.
What should I do to keep the code modular?
there should be no problem importing *.py files form a *.pyp file. What do you mean with "import just doesn't work."?
For example: you can have a formulas.py file (next to your *.pyp) that looks like this:
you can import int in your *.pyp just with
and then use
number = formulas.SomeCalculation()
It gets a little bit more complicated if you want to register plugins in your sub-modules. In that case you would have to hand over the __res__ structure to these modules.
Let me share you an example.
This is a simple hello world program.
In 'hello.pyp' I have (how do I format the text to code?):
def PluginMessage(id, data):
In 'hello_function.py' I have:
When I run this from commandline, in the console I get the error that the hello_function package has not being found. They're on the same folder. I don't see any reason why this is not working
you find information on how to format code in this thread: How to Post Questions.
Any hint why the hello world code I wrote is not working?
you might have to add the pyp file path to the system path using: