Question about Addon box cutter hard opps and python and C

So the addons hard opps and box cutter - these are created with python ? is that right or are they utilizing some C language as well ? The creators (or resellers)of the addon at blendermarket are
“teamCsharp” so I wonder if they are using a C sharp kind of thing ? I read that python can not access edit mode operations so this makes me wonder if this addon uses some C as well ? Can an addon be written with C and Python both ??

My take and I could be wrong or there could be simpler ideas.

  • Blender addons are strictly python

  • To add C or C++ code, you would have to add to Blenders source code and build it from scratch

  • You could potentially get a speed boost by using cython in your addon

  • You could also write your own python modules that wrap C/C++ libraries, then pip install them into Blenders python interpreter and tell the user to install the C libraries or make an installer for them, (probably a different installer for windows / linux / mac )

  • bit messy but install your C libraries and your blender addon calls them using subprocess calls and you would still need installers for win/linux/mac

hope this helps

1 Like

With Python you can access any code written in C. If the code is compiled as a library and functions are exposed externally.

Since for example I have raylib in my computer I might use that.

from ctypes import cdll
raylib = cdll.LoadLibrary(r'O:\programming\lib\raylib\lib\raylib.dll')
print(raylib.GetRandomValue(1, 100))

Imagine that Python itself uses every possible function directly from the C runtime behind the scenes, such as printf, rand, sin, cos. There would be no point at all to have these implemented in 100% Python.

As of the other thing, that if is possible to have CSharp code run inside Blender. It can be done in very simple terms. In very simple cases or for limited uses you can have the addon written in Python as normally, but leave some complex implementations hidden inside the C# code.

(a) c++ code will load the dotnet virtual machine and the relevant dotnet dll compiled programs
(b) the c++ code is compiled as a DLL and exposes one function outside "LoadProgram(...)"
(c) python code template is used as the previous example

The most difficult part of all (almost impossible) is actually to actually create the dotnet API of Blender from scratch.

1 Like