Need help: Own console "Language" in Blender

Hi all,

I’m programming an Addon for sending GCode to CNC the last days as a companion to BlenderCAM. Most things are working and I recognized a lot of people get help at BlenderArtists. So I give it a try as well.

CNC is controlled via GCode. You send a line via serial port and get a line back. This is a console like communication, which can be seen in many GCode sender programs. Misusing the UI is possible (labels, a StringProperty and an operator) - I’m doing this currently - but it is not the best idea and I really want to get rid of this.

I found the file console_shell.py which is alternative console to console_python.py (the standard console within Blender). From the description in the source files all “modules” starting with “console_” and owning an “execute” function should be listed in the menu under View → Languages… → “Console name”. Python is listed here. However, the console_shell is not. This is true for 3.4 as well as 4.0.

I would like to use console_shell.py as a starting point for an own implementation.

I’m wondering, if someone of you know the reason why it is not listed. I really don’t find the reason.

The following files maybe relevant (as mentioned, same in 4.0):
Blender/3.4/scripts/startup/bl_operators/console.py
Blender/3.4/scripts/startup/bl_ui/space_console.py
Blender/3.4/scripts/modules/console_python.py
Blender/3.4/scripts/modules/console_shell.py

Thank you for reading and any help!

I found it by my own. The file was simply not imported. import console_shell let the console appear under languages. However, I didn’t found an import for console_python.

For those trying to write an Addon and want to implement a console:
The file console_xxx.py must be a module. So the file cannot be part of your Addon itself. Here it would become your_module_name.console_xxx.

You can copy the file to either os.path.join(bpy.utils.resource_path('LOCAL'), "scripts", "modules") or os.path.join(bpy.utils.resource_path('USER'), "scripts", "modules"). In both cases you need to import it form your Addon to make it available via import console_xxx.

1 Like