0

I start from scratch a project and would like to use blender as the backend.

I start blender with --python-console --background and would like to open a new window with the 3D Viewport.

I did spend some time looking for resources / examples but without any good approach.

Do you know how to init a 3D Viewport, add it to the shell and make it visible?

Any help would be really appreciated.

Duarte Farrajota Ramos
  • 59,425
  • 39
  • 130
  • 187
ReiRao
  • 1
  • Often also hear bg mode referred to as headless. The lost "head" is the UI. https://blender.stackexchange.com/questions/53358/open-blender-gui-from-py-script – batFINGER Oct 23 '20 at 13:31
  • may be. But if I want to bring in the head by myself, what I need to init / to add to the environment? Something like: Create WindowManager, create Window Object, add to Manager, make visible, ... – ReiRao Oct 23 '20 at 13:42
  • Why are you adding --background if you want to have the UI (see documentation for CLI flags)? What problem are you trying to solve with this? – Robert Gützkow Oct 23 '20 at 13:55
  • I don´t want to have the ui like in normal startup. I just want to use single modules and control them by my python backend. Like a "Render Window" with "own" backend logic & control schemes. – ReiRao Oct 23 '20 at 15:11
  • We are asking this in order to give you a good answer. If you want to use Blender's UI, even in parts, you need to launch Blender without the --background flag. You can however modify the UI through Python or perhaps create application templates. – Robert Gützkow Oct 23 '20 at 15:19
  • is it just not possible to init the gui from scratch or is it just too complicated? If first, then maybe blender is the wrong tool for my project, if second: lets go the hard way. If I start without, I get a blocking window. I just want to have the option to work in console only and perform my actions via the background: I already have a different python class, that acts as backend with database access / webserver & other logical stuff, so I just wanted to load the server in the python environment of blender and start to create objects & visualise them. 2.9 removed the game engine. – ReiRao Oct 23 '20 at 15:23
  • It's the former, with --background set Blender skips UI init steps and you can't trigger them from Python. Now based on your description, it seem like you want to do some form of interactive visualization for a web-app and intended to send the output of Blender's viewport to the client for this? In that case I think it's definitely not the right tool or approach for the job. Overall this sounds like a WebGL-based solution that renders on the client side would be better suited. If you just want to use Blender to render frames on command, then this can be done from Python without any UI. – Robert Gützkow Oct 23 '20 at 16:13
  • BTW there is a fork of Blender called UPBGE that continued the game engine development. – Robert Gützkow Oct 23 '20 at 16:15
  • thank you for the response, still hoping there is a way to init the UI manually, even it will be a pain. Its a bit more complicated than I can describe here. Anyway, if someone has a reference how GUI Initialization is made in Blender, I would give it a try. – ReiRao Oct 23 '20 at 16:24
  • Like I said, you can't from Python and even if you could, the result wouldn't be different from starting Blender without the --background flag. If you are interested how Blender behaves differently when --background is or isn't use, search the source code for G.background. – Robert Gützkow Oct 23 '20 at 16:31

0 Answers0